From bd79352e8005bd8fe0ffa846e3318bc49b3fdd36 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 11 Mar 2018 18:08:26 +0900 Subject: #1204 --- src/web/app/common/views/components/othello.vue | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src/web/app/common') diff --git a/src/web/app/common/views/components/othello.vue b/src/web/app/common/views/components/othello.vue index 81da02d1c4..d650322341 100644 --- a/src/web/app/common/views/components/othello.vue +++ b/src/web/app/common/views/components/othello.vue @@ -78,7 +78,8 @@ export default Vue.extend({ matching: null, invitations: [], connection: null, - connectionId: null + connectionId: null, + pingClock: null }; }, watch: { @@ -112,17 +113,29 @@ export default Vue.extend({ (this as any).api('othello/invitations').then(invitations => { this.invitations = this.invitations.concat(invitations); }); + + this.pingClock = setInterval(() => { + if (this.matching) { + this.connection.send({ + type: 'ping', + id: this.matching.id + }); + } + }, 3000); }, beforeDestroy() { this.connection.off('matched', this.onMatched); this.connection.off('invited', this.onInvited); (this as any).os.streams.othelloStream.dispose(this.connectionId); + + clearInterval(this.pingClock); }, methods: { go(game) { (this as any).api('othello/games/show', { game_id: game.id }).then(game => { + this.matching = null; this.game = game; }); }, @@ -154,11 +167,13 @@ export default Vue.extend({ user_id: invitation.parent.id }).then(game => { if (game) { + this.matching = null; this.game = game; } }); }, onMatched(game) { + this.matching = null; this.game = game; }, onInvited(invite) { -- cgit v1.2.3-freya