merge from develop
This commit is contained in:
commit
f550c5a775
14 changed files with 93 additions and 51 deletions
|
@ -43,6 +43,7 @@ export class RoomConnection implements RoomConnection {
|
|||
private userId: number|null = null;
|
||||
private listeners: Map<string, Function[]> = new Map<string, Function[]>();
|
||||
private static websocketFactory: null|((url: string)=>any) = null; // eslint-disable-line @typescript-eslint/no-explicit-any
|
||||
private closed: boolean = false;
|
||||
|
||||
public static setWebsocketFactory(websocketFactory: (url: string)=>any): void { // eslint-disable-line @typescript-eslint/no-explicit-any
|
||||
RoomConnection.websocketFactory = websocketFactory;
|
||||
|
@ -173,6 +174,7 @@ export class RoomConnection implements RoomConnection {
|
|||
|
||||
public closeConnection(): void {
|
||||
this.socket?.close();
|
||||
this.closed = true;
|
||||
}
|
||||
|
||||
private toPositionMessage(x : number, y : number, direction : string, moving: boolean): PositionMessage {
|
||||
|
@ -389,6 +391,9 @@ export class RoomConnection implements RoomConnection {
|
|||
|
||||
public onServerDisconnected(callback: (event: CloseEvent) => void): void {
|
||||
this.socket.addEventListener('close', (event) => {
|
||||
if (this.closed === true) {
|
||||
return;
|
||||
}
|
||||
console.log('Socket closed with code '+event.code+". Reason: "+event.reason);
|
||||
if (event.code === 1000) {
|
||||
// Normal closure case
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue