Merge pull request #285 from thecodingmachine/fixdisconnect
Fixing disconnect triggering reconnect
This commit is contained in:
commit
8773989bbe
@ -1,6 +1,6 @@
|
|||||||
import Jwt from "jsonwebtoken";
|
import Jwt from "jsonwebtoken";
|
||||||
import {ADMIN_API_TOKEN, ADMIN_API_URL, SECRET_KEY, URL_ROOM_STARTED} from "../Enum/EnvironmentVariable"; //TODO fix import by "_Enum/..."
|
import {ADMIN_API_TOKEN, ADMIN_API_URL, SECRET_KEY, URL_ROOM_STARTED} from "../Enum/EnvironmentVariable"; //TODO fix import by "_Enum/..."
|
||||||
import { uuid } from 'uuidv4';
|
import { v4 } from 'uuid';
|
||||||
import {HttpRequest, HttpResponse, TemplatedApp} from "uWebSockets.js";
|
import {HttpRequest, HttpResponse, TemplatedApp} from "uWebSockets.js";
|
||||||
import {BaseController} from "./BaseController";
|
import {BaseController} from "./BaseController";
|
||||||
import Axios from "axios";
|
import Axios from "axios";
|
||||||
@ -63,7 +63,7 @@ export class AuthenticateController extends BaseController {
|
|||||||
mapUrlStart = data.mapUrlStart;
|
mapUrlStart = data.mapUrlStart;
|
||||||
newUrl = this.getNewUrlOnAdminAuth(data)
|
newUrl = this.getNewUrlOnAdminAuth(data)
|
||||||
} else {
|
} else {
|
||||||
userUuid = uuid();
|
userUuid = v4();
|
||||||
mapUrlStart = host.replace('api.', 'maps.') + URL_ROOM_STARTED;
|
mapUrlStart = host.replace('api.', 'maps.') + URL_ROOM_STARTED;
|
||||||
newUrl = null;
|
newUrl = null;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import {App} from "../Server/sifrr.server";
|
import {App} from "../Server/sifrr.server";
|
||||||
|
|
||||||
import {uuid} from "uuidv4";
|
import {v4} from "uuid";
|
||||||
import {HttpRequest, HttpResponse} from "uWebSockets.js";
|
import {HttpRequest, HttpResponse} from "uWebSockets.js";
|
||||||
import {BaseController} from "./BaseController";
|
import {BaseController} from "./BaseController";
|
||||||
import { Readable } from 'stream'
|
import { Readable } from 'stream'
|
||||||
@ -51,7 +51,7 @@ export class FileController extends BaseController {
|
|||||||
})
|
})
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const audioMessageId = uuid();
|
const audioMessageId = v4();
|
||||||
|
|
||||||
const params = await res.formData({
|
const params = await res.formData({
|
||||||
onFile: (fieldname: string,
|
onFile: (fieldname: string,
|
||||||
|
@ -16,7 +16,7 @@ import {PointInterface} from "../Model/Websocket/PointInterface";
|
|||||||
import {isWebRtcSignalMessageInterface} from "../Model/Websocket/WebRtcSignalMessage";
|
import {isWebRtcSignalMessageInterface} from "../Model/Websocket/WebRtcSignalMessage";
|
||||||
import {UserInGroupInterface} from "../Model/Websocket/UserInGroupInterface";
|
import {UserInGroupInterface} from "../Model/Websocket/UserInGroupInterface";
|
||||||
import {isItemEventMessageInterface} from "../Model/Websocket/ItemEventMessage";
|
import {isItemEventMessageInterface} from "../Model/Websocket/ItemEventMessage";
|
||||||
import {uuid} from 'uuidv4';
|
import { v4 as uuidv4 } from 'uuid';
|
||||||
import {GroupUpdateInterface} from "_Model/Websocket/GroupUpdateInterface";
|
import {GroupUpdateInterface} from "_Model/Websocket/GroupUpdateInterface";
|
||||||
import {Movable} from "../Model/Movable";
|
import {Movable} from "../Model/Movable";
|
||||||
import {
|
import {
|
||||||
@ -135,7 +135,7 @@ export class IoSocketController {
|
|||||||
if (ALLOW_ARTILLERY) {
|
if (ALLOW_ARTILLERY) {
|
||||||
return {
|
return {
|
||||||
token,
|
token,
|
||||||
userUuid: uuid()
|
userUuid: uuidv4()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new Error("In order to perform a load-testing test on this environment, you must set the ALLOW_ARTILLERY environment variable to 'true'");
|
throw new Error("In order to perform a load-testing test on this environment, you must set the ALLOW_ARTILLERY environment variable to 'true'");
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import { World, ConnectCallback, DisconnectCallback } from "./World";
|
import { ConnectCallback, DisconnectCallback } from "./World";
|
||||||
import { User } from "./User";
|
import { User } from "./User";
|
||||||
import {PositionInterface} from "_Model/PositionInterface";
|
import {PositionInterface} from "_Model/PositionInterface";
|
||||||
import {uuid} from "uuidv4";
|
|
||||||
import {Movable} from "_Model/Movable";
|
import {Movable} from "_Model/Movable";
|
||||||
import {PositionNotifier} from "_Model/PositionNotifier";
|
import {PositionNotifier} from "_Model/PositionNotifier";
|
||||||
|
|
||||||
|
@ -36,10 +36,8 @@ export class ConsoleGlobalMessageManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
initialise() {
|
initialise() {
|
||||||
try {
|
for (const elem of document.getElementsByClassName(CLASS_CONSOLE_MESSAGE)) {
|
||||||
HtmlUtils.removeElementByIdOrFail(CLASS_CONSOLE_MESSAGE);
|
elem.remove();
|
||||||
}catch (err){
|
|
||||||
console.error(err);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const typeConsole = document.createElement('input');
|
const typeConsole = document.createElement('input');
|
||||||
|
@ -10,7 +10,7 @@ interface LoginApiData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class ConnectionManager {
|
class ConnectionManager {
|
||||||
private initPromise: Promise<LoginApiData> = Promise.reject();
|
private initPromise!: Promise<LoginApiData>;
|
||||||
private mapUrlStart: string|null = null;
|
private mapUrlStart: string|null = null;
|
||||||
|
|
||||||
private authToken:string|null = null;
|
private authToken:string|null = null;
|
||||||
|
@ -43,6 +43,7 @@ export class RoomConnection implements RoomConnection {
|
|||||||
private userId: number|null = null;
|
private userId: number|null = null;
|
||||||
private listeners: Map<string, Function[]> = new Map<string, Function[]>();
|
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 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
|
public static setWebsocketFactory(websocketFactory: (url: string)=>any): void { // eslint-disable-line @typescript-eslint/no-explicit-any
|
||||||
RoomConnection.websocketFactory = websocketFactory;
|
RoomConnection.websocketFactory = websocketFactory;
|
||||||
@ -157,6 +158,7 @@ export class RoomConnection implements RoomConnection {
|
|||||||
|
|
||||||
public closeConnection(): void {
|
public closeConnection(): void {
|
||||||
this.socket?.close();
|
this.socket?.close();
|
||||||
|
this.closed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private resolveJoinRoom!: (value?: (RoomJoinedMessageInterface | PromiseLike<RoomJoinedMessageInterface> | undefined)) => void;
|
private resolveJoinRoom!: (value?: (RoomJoinedMessageInterface | PromiseLike<RoomJoinedMessageInterface> | undefined)) => void;
|
||||||
@ -389,6 +391,9 @@ export class RoomConnection implements RoomConnection {
|
|||||||
|
|
||||||
public onServerDisconnected(callback: (event: CloseEvent) => void): void {
|
public onServerDisconnected(callback: (event: CloseEvent) => void): void {
|
||||||
this.socket.addEventListener('close', (event) => {
|
this.socket.addEventListener('close', (event) => {
|
||||||
|
if (this.closed === true) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
console.log('Socket closed with code '+event.code+". Reason: "+event.reason);
|
console.log('Socket closed with code '+event.code+". Reason: "+event.reason);
|
||||||
if (event.code === 1000) {
|
if (event.code === 1000) {
|
||||||
// Normal closure case
|
// Normal closure case
|
||||||
|
Loading…
Reference in New Issue
Block a user