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:
@@ -26,6 +26,7 @@ import {
|
||||
QueryJitsiJwtMessage,
|
||||
SendJitsiJwtMessage,
|
||||
CharacterLayerMessage,
|
||||
PingMessage,
|
||||
SendUserMessage
|
||||
} from "../Messages/generated/messages_pb"
|
||||
|
||||
@@ -42,6 +43,8 @@ import {
|
||||
} from "./ConnexionModels";
|
||||
import {BodyResourceDescriptionInterface} from "../Phaser/Entity/body_character";
|
||||
|
||||
const manualPingDelay = 20000;
|
||||
|
||||
export class RoomConnection implements RoomConnection {
|
||||
private readonly socket: WebSocket;
|
||||
private userId: number|null = null;
|
||||
@@ -84,7 +87,9 @@ export class RoomConnection implements RoomConnection {
|
||||
this.socket.binaryType = 'arraybuffer';
|
||||
|
||||
this.socket.onopen = (ev) => {
|
||||
//console.log('WS connected');
|
||||
//we manually ping every 20s to not be logged out by the server, even when the game is in background.
|
||||
const pingMessage = new PingMessage();
|
||||
setInterval(() => this.socket.send(pingMessage.serializeBinary().buffer), manualPingDelay);
|
||||
};
|
||||
|
||||
this.socket.onmessage = (messageEvent) => {
|
||||
|
||||
Reference in New Issue
Block a user