Created
June 28, 2019 11:15
-
-
Save buesing/0c8ea45694cb53be15d54dfc7c34b0f1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(window).on('beforeunload', () => { | |
if (this.isOpponentConnected) { | |
// tell opponent we disconnected | |
this.statusRecord.set(`player-${this.isHost ? 1 : 2}`, {action: ACTION.DISCONNECT}); | |
} | |
if (this.statusRecord) { | |
// delete all records | |
this.statusRecord.discard(); | |
this.statusRecord.delete(); | |
this.paddle1Record.discard(); | |
this.paddle1Record.delete(); | |
this.paddle2Record.discard(); | |
this.paddle2Record.delete(); | |
this.hitRecord.discard(); | |
this.hitRecord.delete(); | |
this.missRecord.discard(); | |
this.missRecord.delete(); | |
this.pingRecord.discard(); | |
this.pingRecord.delete(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment