quit game and clear interval

This commit is contained in:
ntr 2018-10-24 16:19:27 +11:00
parent 5886f9413b
commit 8be14ac546
3 changed files with 19 additions and 3 deletions

View File

@ -19,9 +19,10 @@
"key": "^0.1.11",
"keymaster": "^1.6.2",
"lodash": "^4.17.11",
"parcel": "^1.9.7",
"phaser": "^3.15.1",
"preact": "^8.3.1",
"preact-redux": "^2.0.3",
"parcel": "^1.9.7",
"redux": "^4.0.0"
},
"devDependencies": {

View File

@ -11,8 +11,14 @@ const GameContainer = require('./game.container');
const addState = connect(
function receiveState(state) {
const {game} = state;
return {game};
const { game, ws } = state;
if (!game) {
console.log('out of game');
ws.clearGameStateInterval();
}
return { game };
},
function receiveDispatch(dispatch) {
function setGame(game) {

View File

@ -151,6 +151,14 @@ function createSocket(store) {
}
// -------------
// Events
// -------------
function clearGameStateInterval() {
clearInterval(gameStateTimeout);
}
// -------------
// Handling
// -------------
@ -182,6 +190,7 @@ function createSocket(store) {
}
return {
clearGameStateInterval,
sendAccountLogin,
sendAccountRegister,
sendGameState,