1
0
mirror of https://github.com/misskey-dev/misskey.git synced 2026-05-06 02:26:04 +02:00
This commit is contained in:
syuilo
2018-03-11 18:08:26 +09:00
parent 04cc63ac64
commit bd79352e80
7 changed files with 89 additions and 7 deletions

View File

@@ -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) {