filthy timeout

This commit is contained in:
ntr
2018-10-23 16:51:12 +11:00
parent af9f2c479d
commit cf7501b442
4 changed files with 45 additions and 2 deletions
+1
View File
@@ -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);
+9
View File
@@ -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,