timeout
This commit is contained in:
parent
9217cf2a91
commit
1874db2902
@ -12,8 +12,7 @@ const addState = connect(
|
|||||||
const { game, instance, ws, account } = state;
|
const { game, instance, ws, account } = state;
|
||||||
|
|
||||||
if (!game) {
|
if (!game) {
|
||||||
console.log('clear gs interval');
|
ws.clearGameStateTimeout();
|
||||||
// ws.clearGameStateInterval();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return { game, instance, account };
|
return { game, instance, account };
|
||||||
|
|||||||
@ -18,9 +18,11 @@ function registerEvents(store) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function setGame(game) {
|
function setGame(game) {
|
||||||
const { game: currentGame } = store.getState();
|
const { game: currentGame, ws } = store.getState();
|
||||||
if (game && currentGame) {
|
if (game && currentGame) {
|
||||||
if (game.resolved.length !== currentGame.resolved.length) {
|
if (game.resolved.length !== currentGame.resolved.length) {
|
||||||
|
// stop fetching the game state til animations are done
|
||||||
|
ws.clearGameStateTimeout();
|
||||||
const newRes = game.resolved.slice(currentGame.resolved.length);
|
const newRes = game.resolved.slice(currentGame.resolved.length);
|
||||||
return eachSeries(newRes, (r, cb) => {
|
return eachSeries(newRes, (r, cb) => {
|
||||||
if (['Disable', 'TargetKo'].includes(r.event[0])) return cb();
|
if (['Disable', 'TargetKo'].includes(r.event[0])) return cb();
|
||||||
@ -29,7 +31,10 @@ function registerEvents(store) {
|
|||||||
}, err => {
|
}, err => {
|
||||||
if (err) return console.error(err);
|
if (err) return console.error(err);
|
||||||
store.dispatch(actions.setResolution(null));
|
store.dispatch(actions.setResolution(null));
|
||||||
|
// update the game
|
||||||
store.dispatch(actions.setGame(game));
|
store.dispatch(actions.setGame(game));
|
||||||
|
// get the latest state and restart polling
|
||||||
|
ws.sendGameState(currentGame.id);
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -174,11 +174,18 @@ function createSocket(events) {
|
|||||||
events.setCrypList(cryps);
|
events.setCrypList(cryps);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let gameStateTimeout;
|
||||||
function gameState(response) {
|
function gameState(response) {
|
||||||
const [structName, game] = response;
|
const [structName, game] = response;
|
||||||
|
clearInterval(gameStateTimeout);
|
||||||
|
gameStateTimeout = setTimeout(() => sendGameState(game.id), 1000);
|
||||||
events.setGame(game);
|
events.setGame(game);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function clearGameStateTimeout() {
|
||||||
|
clearTimeout(gameStateTimeout);
|
||||||
|
}
|
||||||
|
|
||||||
function crypSpawn(response) {
|
function crypSpawn(response) {
|
||||||
const [structName, cryp] = response;
|
const [structName, cryp] = response;
|
||||||
}
|
}
|
||||||
@ -289,6 +296,7 @@ function createSocket(events) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
clearGameStateTimeout,
|
||||||
sendAccountLogin,
|
sendAccountLogin,
|
||||||
sendAccountCreate,
|
sendAccountCreate,
|
||||||
sendAccountDemo,
|
sendAccountDemo,
|
||||||
|
|||||||
@ -25,6 +25,13 @@
|
|||||||
* resolve animations + effects
|
* resolve animations + effects
|
||||||
|
|
||||||
*SERVER*
|
*SERVER*
|
||||||
|
authentication endpoint
|
||||||
|
hit /auth with un/pw or token
|
||||||
|
invalidate previous token
|
||||||
|
generate new token and return
|
||||||
|
attach token to websocket
|
||||||
|
ez
|
||||||
|
|
||||||
consolidate buffs debuffs and disables
|
consolidate buffs debuffs and disables
|
||||||
no more red/blue
|
no more red/blue
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user