FIX: in dev mode, sockets won't be closed to prevent conflicts with live-reloading

This commit is contained in:
kharhamel 2020-11-10 15:24:02 +01:00
parent 1080328afa
commit 5a1147866c
3 changed files with 5 additions and 0 deletions

View file

@ -1,5 +1,6 @@
import {ExSocketInterface} from "_Model/Websocket/ExSocketInterface";
import {BatchMessage, ErrorMessage, ServerToClientMessage, SubMessage} from "../Messages/generated/messages_pb";
import {DEV_MODE} from "../Enum/EnvironmentVariable";
export function emitInBatch(socket: ExSocketInterface, payload: SubMessage): void {
socket.batchedMessages.addPayload(payload);
@ -52,6 +53,7 @@ export function emitError(Client: ExSocketInterface, message: string): void {
export const pongMaxInterval = 30000; // the maximum duration (in ms) between pongs before we shutdown the connexion.
export function refresLogoutTimerOnPong(ws: ExSocketInterface): void {
if (DEV_MODE) return; //this feature is disabled in dev mode as it clashes with live reload.
if(ws.pongTimeout) clearTimeout(ws.pongTimeout);
ws.pongTimeout = setTimeout(() => {
ws.close();