FIX: remove the ping and pong overrides server side in favor of and idleTimeout and added a manual ping client side
This commit is contained in:
parent
5a1147866c
commit
9b64a970b5
7 changed files with 14 additions and 39 deletions
|
@ -1,6 +1,5 @@
|
|||
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);
|
||||
|
@ -19,22 +18,6 @@ export function emitInBatch(socket: ExSocketInterface, payload: SubMessage): voi
|
|||
socket.batchTimeout = null;
|
||||
}, 100);
|
||||
}
|
||||
|
||||
// If we send a message, we don't need to keep the connection alive
|
||||
resetPing(socket);
|
||||
}
|
||||
|
||||
export function resetPing(ws: ExSocketInterface): void {
|
||||
if (ws.pingTimeout) {
|
||||
clearTimeout(ws.pingTimeout);
|
||||
}
|
||||
ws.pingTimeout = setTimeout(() => {
|
||||
if (ws.disconnecting) {
|
||||
return;
|
||||
}
|
||||
ws.ping();
|
||||
resetPing(ws);
|
||||
}, 29000);
|
||||
}
|
||||
|
||||
export function emitError(Client: ExSocketInterface, message: string): void {
|
||||
|
@ -50,12 +33,3 @@ export function emitError(Client: ExSocketInterface, message: string): void {
|
|||
console.warn(message);
|
||||
}
|
||||
|
||||
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();
|
||||
}, pongMaxInterval);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue