summaryrefslogtreecommitdiff
path: root/server.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2023-07-13 14:09:10 +0200
committerTor Andersson <tor@ccxvii.net>2023-07-13 14:10:20 +0200
commit359e2c62ca54cf41d70635a994ca748fcca50f14 (patch)
treea5ca4417ecc9e86b1df12d938512e99b7e96069f /server.js
parent66f983b8c9bfe547835741fd93d003d56ddea186 (diff)
downloadserver-359e2c62ca54cf41d70635a994ca748fcca50f14.tar.gz
Handle websocket errors.
Diffstat (limited to 'server.js')
-rw-r--r--server.js7
1 files changed, 6 insertions, 1 deletions
diff --git a/server.js b/server.js
index 65f5a7a..3fc6274 100644
--- a/server.js
+++ b/server.js
@@ -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())
}
})