Added ws keep alive event on 55 second interval
This commit is contained in:
1 parent
c8adc77938
commit
d0ca20b162
1 file changed
+8
-2
@@ -25,6 +25,7 @@ export const useGameStore = defineStore('game', {
|
|||||||
acceptAnswers: false,
|
acceptAnswers: false,
|
||||||
isPlayerChoosing: false,
|
isPlayerChoosing: false,
|
||||||
chosenEntry: undefined,
|
chosenEntry: undefined,
|
||||||
|
keepAliveInterval: undefined,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
@@ -222,7 +223,10 @@ export const useGameStore = defineStore('game', {
|
|||||||
}, 5000);
|
}, 5000);
|
||||||
|
|
||||||
this.websocketConnection.onopen = ( _event ) => {
|
this.websocketConnection.onopen = ( _event ) => {
|
||||||
clearTimeout(timeout);
|
this.keepAliveInterval = setInterval( () => {
|
||||||
|
this.sendEvent("keepAlive", {} );
|
||||||
|
}, 55000);
|
||||||
|
clearTimeout(timeout);
|
||||||
resolve();
|
resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -244,7 +248,9 @@ export const useGameStore = defineStore('game', {
|
|||||||
console.error("Websocket Error");
|
console.error("Websocket Error");
|
||||||
};
|
};
|
||||||
this.websocketConnection.onclose = ( event ) => {
|
this.websocketConnection.onclose = ( event ) => {
|
||||||
const userStore = useUserStore();
|
clearInterval( this.keepAliveInterval );
|
||||||
|
this.keepAliveInterval = undefined;
|
||||||
|
const userStore = useUserStore();
|
||||||
userStore.resetInitialUserDataPromise();
|
userStore.resetInitialUserDataPromise();
|
||||||
userStore.initialUserPromise
|
userStore.initialUserPromise
|
||||||
.then( ( userData ) => {
|
.then( ( userData ) => {
|
||||||
|
|||||||
Reference in new issue
Block a user