newsproutsmedia / chat

Chat site using socket.io
https://chatapp.newsproutsmedia.com
0 stars 0 forks source link

(feature, bug) System: Add socket exists check for all server-side socket event listeners #124

Closed newsproutsmedia closed 3 years ago

newsproutsmedia commented 3 years ago

Problem: Crash occurs if a client with no socket attempts to interact with the system. This might happen if they time out but still have their chat window open.

To fix the problem, check that the client socket exists at beginning of each server-side socket listener.

if(this.io.sockets.sockets[SOCKET_ID] === undefined) {
 // ... return code if socket doesn't exist
}