diff options
author | Tor Andersson <tor@ccxvii.net> | 2023-07-13 14:09:10 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2023-07-13 14:10:20 +0200 |
commit | 359e2c62ca54cf41d70635a994ca748fcca50f14 (patch) | |
tree | a5ca4417ecc9e86b1df12d938512e99b7e96069f | |
parent | 66f983b8c9bfe547835741fd93d003d56ddea186 (diff) | |
download | server-359e2c62ca54cf41d70635a994ca748fcca50f14.tar.gz |
Handle websocket errors.
-rw-r--r-- | server.js | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -2364,6 +2364,11 @@ wss.on('connection', (socket, req) => { delete game_clients[socket.game_id] }) + socket.on('error', (err) => { + SLOG(socket, "ERROR" + err) + socket.close(1000, err.toString()) + }) + socket.on('message', (data) => { try { let [ cmd, arg ] = JSON.parse(data) @@ -2372,7 +2377,7 @@ wss.on('connection', (socket, req) => { else handle_observer_message(socket, cmd, arg) } catch (err) { - send_message(socket, 'error', err) + send_message(socket, 'error', err.toString()) } }) |