X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=client%2Fsrc%2Fviews%2FMyGames.vue;h=7615308b730bc721ae73c543146279d441a5fbcd;hp=3c2f460b41da35b7ab60f7f3a1a2a5d16e50a441;hb=68e3aa8c7a92efe3461bfc5c904f9763bca5d2da;hpb=a2bd587aebc0104db71f9404aadeec72c9141102 diff --git a/client/src/views/MyGames.vue b/client/src/views/MyGames.vue index 3c2f460b..7615308b 100644 --- a/client/src/views/MyGames.vue +++ b/client/src/views/MyGames.vue @@ -143,7 +143,10 @@ export default { methods: { cleanBeforeDestroy: function() { window.removeEventListener("beforeunload", this.cleanBeforeDestroy); + this.conn.removeEventListener("message", this.socketMessageListener); + this.conn.removeEventListener("close", this.socketCloseListener); this.conn.send(JSON.stringify({code: "disconnect"})); + this.conn = null; }, setDisplay: function(type, e) { this.display = type; @@ -182,6 +185,7 @@ export default { }); }, socketMessageListener: function(msg) { + if (!this.conn) return; const data = JSON.parse(msg.data); let gamesArrays = { "corr": this.corrGames, @@ -262,16 +266,18 @@ export default { game.players[0].sid == this.st.user.sid ? game.players[1].sid : game.players[0].sid; - this.conn.send( - JSON.stringify( - { - code: "mabort", - gid: game.id, - // NOTE: target might not be online - target: oppsid - } - ) - ); + if (!!this.conn) { + this.conn.send( + JSON.stringify( + { + code: "mabort", + gid: game.id, + // NOTE: target might not be online + target: oppsid + } + ) + ); + } } else if (!game.deletedByWhite || !game.deletedByBlack) { // Set score if game isn't deleted on server: