Merge pull request #412 from thecodingmachine/fix/iHatePong

FIX: remove the ping and pong overrides server side
This commit is contained in:
Kharhamel 2020-11-12 10:28:02 +01:00 committed by GitHub
commit b468f03603
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 14 additions and 39 deletions

View file

@ -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) => {