filthy timeout
This commit is contained in:
@@ -7,6 +7,7 @@ const Game = require('./game');
|
||||
const addState = connect(
|
||||
function receiveState(state) {
|
||||
const { ws, game, account, activeSkill, activeIncoming } = state;
|
||||
|
||||
function selectSkillTarget(targetTeamId) {
|
||||
if (activeSkill) {
|
||||
return ws.sendGameSkill(game.id, activeSkill.crypId, targetTeamId, activeSkill.skill);
|
||||
|
||||
@@ -18,6 +18,8 @@ function errorToast(err) {
|
||||
function createSocket(store) {
|
||||
let ws;
|
||||
|
||||
let gameStateTimeout;
|
||||
|
||||
function connect() {
|
||||
ws = new WebSocket('ws://localhost:40000');
|
||||
ws.binaryType = 'arraybuffer';
|
||||
@@ -71,6 +73,8 @@ function createSocket(store) {
|
||||
|
||||
function gameState(response) {
|
||||
const [structName, game] = response;
|
||||
clearInterval(gameStateTimeout);
|
||||
gameStateTimeout = setTimeout(() => sendGameState(game.id), 1000);
|
||||
store.dispatch(actions.setGame(game));
|
||||
}
|
||||
|
||||
@@ -109,6 +113,10 @@ function createSocket(store) {
|
||||
send({ method: 'cryp_spawn', params: { name } });
|
||||
}
|
||||
|
||||
function sendGameState(id) {
|
||||
send({ method: 'game_state', params: { id } });
|
||||
}
|
||||
|
||||
function sendGamePve(id) {
|
||||
send({ method: 'game_pve', params: { id } });
|
||||
}
|
||||
@@ -174,6 +182,7 @@ function createSocket(store) {
|
||||
return {
|
||||
sendAccountLogin,
|
||||
sendAccountRegister,
|
||||
sendGameState,
|
||||
sendGamePve,
|
||||
sendGamePvp,
|
||||
sendGameJoin,
|
||||
|
||||
Reference in New Issue
Block a user