timeout
This commit is contained in:
parent
9217cf2a91
commit
1874db2902
@ -12,8 +12,7 @@ const addState = connect(
|
||||
const { game, instance, ws, account } = state;
|
||||
|
||||
if (!game) {
|
||||
console.log('clear gs interval');
|
||||
// ws.clearGameStateInterval();
|
||||
ws.clearGameStateTimeout();
|
||||
}
|
||||
|
||||
return { game, instance, account };
|
||||
|
||||
@ -18,9 +18,11 @@ function registerEvents(store) {
|
||||
}
|
||||
|
||||
function setGame(game) {
|
||||
const { game: currentGame } = store.getState();
|
||||
const { game: currentGame, ws } = store.getState();
|
||||
if (game && currentGame) {
|
||||
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);
|
||||
return eachSeries(newRes, (r, cb) => {
|
||||
if (['Disable', 'TargetKo'].includes(r.event[0])) return cb();
|
||||
@ -29,7 +31,10 @@ function registerEvents(store) {
|
||||
}, err => {
|
||||
if (err) return console.error(err);
|
||||
store.dispatch(actions.setResolution(null));
|
||||
// update the game
|
||||
store.dispatch(actions.setGame(game));
|
||||
// get the latest state and restart polling
|
||||
ws.sendGameState(currentGame.id);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
@ -174,11 +174,18 @@ function createSocket(events) {
|
||||
events.setCrypList(cryps);
|
||||
}
|
||||
|
||||
let gameStateTimeout;
|
||||
function gameState(response) {
|
||||
const [structName, game] = response;
|
||||
clearInterval(gameStateTimeout);
|
||||
gameStateTimeout = setTimeout(() => sendGameState(game.id), 1000);
|
||||
events.setGame(game);
|
||||
}
|
||||
|
||||
function clearGameStateTimeout() {
|
||||
clearTimeout(gameStateTimeout);
|
||||
}
|
||||
|
||||
function crypSpawn(response) {
|
||||
const [structName, cryp] = response;
|
||||
}
|
||||
@ -289,6 +296,7 @@ function createSocket(events) {
|
||||
}
|
||||
|
||||
return {
|
||||
clearGameStateTimeout,
|
||||
sendAccountLogin,
|
||||
sendAccountCreate,
|
||||
sendAccountDemo,
|
||||
|
||||
@ -25,6 +25,13 @@
|
||||
* resolve animations + effects
|
||||
|
||||
*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
|
||||
no more red/blue
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user