diff --git a/public/scripts/network.js b/public/scripts/network.js index 9ab02d3..ff26d0d 100644 --- a/public/scripts/network.js +++ b/public/scripts/network.js @@ -139,10 +139,12 @@ class ServerConnection { _disconnect() { this.send({ type: 'disconnect' }); - this._socket.onclose = null; - this._socket.close(); - this._socket = null; - Events.fire('ws-disconnected'); + if (this._socket) { + this._socket.onclose = null; + this._socket.close(); + this._socket = null; + Events.fire('ws-disconnected'); + } } _onDisconnect() {