From 6c6a7e6fe45054974225ed75ba0c91456f3ac29a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Mon, 8 Nov 2021 14:30:54 +0100 Subject: [PATCH 01/18] Improving log messages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: David NĂ©grier --- back/src/Model/GameRoom.ts | 2 +- back/src/Services/SocketManager.ts | 2 +- pusher/src/Services/SocketManager.ts | 11 +++++------ 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/back/src/Model/GameRoom.ts b/back/src/Model/GameRoom.ts index 74849fe0..bd3e6971 100644 --- a/back/src/Model/GameRoom.ts +++ b/back/src/Model/GameRoom.ts @@ -484,7 +484,7 @@ export class GameRoom { for (const roomListener of this.roomListeners) { emitErrorOnRoomSocket( roomListener, - "Your map does not seem accessible from the WorkAdventure servers. Is it behind a firewall or a proxy? Your map should be accessible from the WorkAdventure servers. If you use the scripting API in this map, please be aware that server-side checks and variable persistence is disabled." + "Your map '"+this.mapUrl+"' does not seem accessible from the WorkAdventure servers. Is it behind a firewall or a proxy? Your map should be accessible from the WorkAdventure servers. If you use the scripting API in this map, please be aware that server-side checks and variable persistence is disabled." ); } }, 1000); diff --git a/back/src/Services/SocketManager.ts b/back/src/Services/SocketManager.ts index 5efae800..3e8baf61 100644 --- a/back/src/Services/SocketManager.ts +++ b/back/src/Services/SocketManager.ts @@ -308,7 +308,7 @@ export class SocketManager { const user = room.join(socket, joinRoomMessage); clientEventsEmitter.emitClientJoin(user.uuid, roomId); - console.log(new Date().toISOString() + " A user joined"); + console.log(new Date().toISOString() + " user '"+user.uuid+"' joined room '"+roomId+"'"); return { room, user }; } diff --git a/pusher/src/Services/SocketManager.ts b/pusher/src/Services/SocketManager.ts index 1761f1bd..40d58b64 100644 --- a/pusher/src/Services/SocketManager.ts +++ b/pusher/src/Services/SocketManager.ts @@ -166,7 +166,7 @@ export class SocketManager implements ZoneEventListener { joinRoomMessage.addCharacterlayer(characterLayerMessage); } - console.log("Calling joinRoom"); + console.log("Calling joinRoom '"+client.roomId+"' for client "+client.userUuid); const apiClient = await apiClientRepository.getClient(client.roomId); const streamToPusher = apiClient.joinRoom(); clientEventsEmitter.emitClientJoin(client.userUuid, client.roomId); @@ -194,17 +194,16 @@ export class SocketManager implements ZoneEventListener { } }) .on("end", () => { - console.warn("Connection lost to back server"); // Let's close the front connection if the back connection is closed. This way, we can retry connecting from the start. if (!client.disconnecting) { this.closeWebsocketConnection(client, 1011, "Connection lost to back server"); } - console.log("A user left"); + console.log("Closed connection for user '"+client.userUuid+"' to back server "+apiClient.getChannel().getTarget()); }) .on("error", (err: Error) => { - console.error("Error in connection to back server:", err); + console.error("Error in connection to back server '"+apiClient.getChannel().getTarget()+"':", err); if (!client.disconnecting) { - this.closeWebsocketConnection(client, 1011, "Error while connecting to back server"); + this.closeWebsocketConnection(client, 1011, "Error while connecting to back server '"+apiClient.getChannel().getTarget()+"'"); } }); @@ -353,7 +352,7 @@ export class SocketManager implements ZoneEventListener { } finally { //delete Client.roomId; clientEventsEmitter.emitClientLeave(socket.userUuid, socket.roomId); - console.log("A user left"); + console.log("User '"+socket.userUuid+"' left"); } } } finally { From c573e9fbaf29c8aae6dc59b9a2e3078030723587 Mon Sep 17 00:00:00 2001 From: Alexis Faizeau Date: Mon, 8 Nov 2021 14:45:25 +0100 Subject: [PATCH 02/18] Implement no floating promises on eslint rules --- back/.eslintrc.json | 1 + back/src/Server/server/formdata.ts | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/back/.eslintrc.json b/back/.eslintrc.json index 3aab37d9..0b5e39da 100644 --- a/back/.eslintrc.json +++ b/back/.eslintrc.json @@ -25,6 +25,7 @@ ], "rules": { "no-unused-vars": "off", + "@typescript-eslint/no-floating-promises": "error", "@typescript-eslint/no-explicit-any": "error" } } diff --git a/back/src/Server/server/formdata.ts b/back/src/Server/server/formdata.ts index 66e51db4..0e17de78 100644 --- a/back/src/Server/server/formdata.ts +++ b/back/src/Server/server/formdata.ts @@ -47,7 +47,10 @@ function formData( if (typeof options.tmpDir === "string") { if (typeof options.filename === "function") filename = options.filename(filename); const fileToSave = join(options.tmpDir, filename); - mkdirp(dirname(fileToSave)); + mkdirp(dirname(fileToSave)).then( + () => {}, + () => {} + ); file.pipe(createWriteStream(fileToSave)); value.filePath = fileToSave; From 6a195be814a9b97438f74b5f3ce00a170fc62593 Mon Sep 17 00:00:00 2001 From: Alexis Faizeau Date: Mon, 8 Nov 2021 17:44:44 +0100 Subject: [PATCH 03/18] Implement logger on back --- back/package.json | 3 +- back/server.ts | 13 +- back/src/Model/GameRoom.ts | 11 +- back/src/RoomManager.ts | 41 ++--- back/src/Server/server/formdata.ts | 3 +- back/src/Services/CpuTracker.ts | 13 +- back/src/Services/Logger.ts | 16 ++ back/src/Services/MapFetcher.ts | 3 +- back/src/Services/MessageHelpers.ts | 11 +- back/src/Services/RedisClient.ts | 3 +- .../Repository/VariablesRepository.ts | 3 +- back/src/Services/SocketManager.ts | 35 ++-- back/src/Services/VariablesManager.ts | 5 +- back/tsconfig.json | 2 +- back/yarn.lock | 164 +++++++++++++++++- package.json | 3 +- yarn.lock | 7 +- 17 files changed, 260 insertions(+), 76 deletions(-) create mode 100644 back/src/Services/Logger.ts diff --git a/back/package.json b/back/package.json index aacd0c96..817295ce 100644 --- a/back/package.json +++ b/back/package.json @@ -55,7 +55,8 @@ "query-string": "^6.13.3", "redis": "^3.1.2", "uWebSockets.js": "uNetworking/uWebSockets.js#v18.5.0", - "uuidv4": "^6.0.7" + "uuidv4": "^6.0.7", + "winston": "^3.3.3" }, "devDependencies": { "@types/busboy": "^0.2.3", diff --git a/back/server.ts b/back/server.ts index 8d761719..1026bc3e 100644 --- a/back/server.ts +++ b/back/server.ts @@ -1,15 +1,16 @@ // lib/server.ts import App from "./src/App"; import grpc from "grpc"; -import {roomManager} from "./src/RoomManager"; -import {IRoomManagerServer, RoomManagerService} from "./src/Messages/generated/messages_grpc_pb"; -import {HTTP_PORT, GRPC_PORT} from "./src/Enum/EnvironmentVariable"; +import { roomManager } from "./src/RoomManager"; +import { IRoomManagerServer, RoomManagerService } from "./src/Messages/generated/messages_grpc_pb"; +import { HTTP_PORT, GRPC_PORT } from "./src/Enum/EnvironmentVariable"; +import log from "./src/Services/Logger"; -App.listen(HTTP_PORT, () => console.log(`WorkAdventure HTTP API starting on port %d!`, HTTP_PORT)) +App.listen(HTTP_PORT, () => log.info(`WorkAdventure HTTP API starting on port %d!`, HTTP_PORT)); const server = new grpc.Server(); server.addService(RoomManagerService, roomManager); -server.bind('0.0.0.0:'+GRPC_PORT, grpc.ServerCredentials.createInsecure()); +server.bind("0.0.0.0:" + GRPC_PORT, grpc.ServerCredentials.createInsecure()); server.start(); -console.log('WorkAdventure HTTP/2 API starting on port %d!', GRPC_PORT); +log.info("WorkAdventure HTTP/2 API starting on port %d!", GRPC_PORT); diff --git a/back/src/Model/GameRoom.ts b/back/src/Model/GameRoom.ts index bd3e6971..a5af7732 100644 --- a/back/src/Model/GameRoom.ts +++ b/back/src/Model/GameRoom.ts @@ -26,6 +26,7 @@ import { VariablesManager } from "../Services/VariablesManager"; import { ADMIN_API_URL } from "../Enum/EnvironmentVariable"; import { LocalUrlError } from "../Services/LocalUrlError"; import { emitErrorOnRoomSocket } from "../Services/MessageHelpers"; +import log from "../Services/Logger"; export type ConnectCallback = (user: User, group: Group) => void; export type DisconnectCallback = (user: User, group: Group) => void; @@ -151,7 +152,7 @@ export class GameRoom { public leave(user: User) { const userObj = this.users.get(user.id); if (userObj === undefined) { - console.warn("User ", user.id, "does not belong to this game room! It should!"); + log.warn("User ", user.id, "does not belong to this game room! It should!"); } if (userObj !== undefined && typeof userObj.group !== "undefined") { this.leaveGroup(userObj); @@ -411,7 +412,7 @@ export class GameRoom { const match = /\/_\/[^/]+\/(.+)/.exec(roomUrlObj.pathname); if (!match) { - console.error("Unexpected room URL", roomUrl); + log.error("Unexpected room URL", roomUrl); throw new Error('Unexpected room URL "' + roomUrl + '"'); } @@ -427,7 +428,7 @@ export class GameRoom { const result = await adminApi.fetchMapDetails(roomUrl); if (!isMapDetailsData(result)) { - console.error("Unexpected room details received from server", result); + log.error("Unexpected room details received from server", result); throw new Error("Unexpected room details received from server"); } return result; @@ -484,7 +485,9 @@ export class GameRoom { for (const roomListener of this.roomListeners) { emitErrorOnRoomSocket( roomListener, - "Your map '"+this.mapUrl+"' does not seem accessible from the WorkAdventure servers. Is it behind a firewall or a proxy? Your map should be accessible from the WorkAdventure servers. If you use the scripting API in this map, please be aware that server-side checks and variable persistence is disabled." + "Your map '" + + this.mapUrl + + "' does not seem accessible from the WorkAdventure servers. Is it behind a firewall or a proxy? Your map should be accessible from the WorkAdventure servers. If you use the scripting API in this map, please be aware that server-side checks and variable persistence is disabled." ); } }, 1000); diff --git a/back/src/RoomManager.ts b/back/src/RoomManager.ts index 8dbde018..65a71e02 100644 --- a/back/src/RoomManager.ts +++ b/back/src/RoomManager.ts @@ -31,6 +31,7 @@ import { User, UserSocket } from "./Model/User"; import { GameRoom } from "./Model/GameRoom"; import Debug from "debug"; import { Admin } from "./Model/Admin"; +import log from "./Services/Logger"; const debug = Debug("roommanager"); @@ -40,7 +41,7 @@ export type RoomSocket = ServerWritableStream { - console.log("joinRoom called"); + log.info("joinRoom called"); let room: GameRoom | null = null; let user: User | null = null; @@ -131,11 +132,11 @@ const roomManager: IRoomManagerServer = { } } } catch (e) { - console.error(e); + log.error(e); emitError(call, e); call.end(); } - })().catch((e) => console.error(e)); + })().catch((e) => log.error(e)); }); call.on("end", () => { @@ -149,7 +150,7 @@ const roomManager: IRoomManagerServer = { }); call.on("error", (err: Error) => { - console.error("An error occurred in joinRoom stream:", err); + log.error("An error occurred in joinRoom stream:", err); }); }, @@ -167,7 +168,7 @@ const roomManager: IRoomManagerServer = { debug("listenZone cancelled"); socketManager .removeZoneListener(call, zoneMessage.getRoomid(), zoneMessage.getX(), zoneMessage.getY()) - .catch((e) => console.error(e)); + .catch((e) => log.error(e)); call.end(); }); @@ -175,12 +176,12 @@ const roomManager: IRoomManagerServer = { debug("listenZone connection closed"); socketManager .removeZoneListener(call, zoneMessage.getRoomid(), zoneMessage.getX(), zoneMessage.getY()) - .catch((e) => console.error(e)); + .catch((e) => log.error(e)); }).on("error", (e) => { - console.error("An error occurred in listenZone stream:", e); + log.error("An error occurred in listenZone stream:", e); socketManager .removeZoneListener(call, zoneMessage.getRoomid(), zoneMessage.getX(), zoneMessage.getY()) - .catch((e) => console.error(e)); + .catch((e) => log.error(e)); call.end(); }); }, @@ -195,22 +196,22 @@ const roomManager: IRoomManagerServer = { call.on("cancelled", () => { debug("listenRoom cancelled"); - socketManager.removeRoomListener(call, roomMessage.getRoomid()).catch((e) => console.error(e)); + socketManager.removeRoomListener(call, roomMessage.getRoomid()).catch((e) => log.error(e)); call.end(); }); call.on("close", () => { debug("listenRoom connection closed"); - socketManager.removeRoomListener(call, roomMessage.getRoomid()).catch((e) => console.error(e)); + socketManager.removeRoomListener(call, roomMessage.getRoomid()).catch((e) => log.error(e)); }).on("error", (e) => { - console.error("An error occurred in listenRoom stream:", e); - socketManager.removeRoomListener(call, roomMessage.getRoomid()).catch((e) => console.error(e)); + log.error("An error occurred in listenRoom stream:", e); + socketManager.removeRoomListener(call, roomMessage.getRoomid()).catch((e) => log.error(e)); call.end(); }); }, adminRoom(call: AdminSocket): void { - console.log("adminRoom called"); + log.info("adminRoom called"); const admin = new Admin(call); let room: GameRoom | null = null; @@ -225,7 +226,7 @@ const roomManager: IRoomManagerServer = { .then((gameRoom: GameRoom) => { room = gameRoom; }) - .catch((e) => console.error(e)); + .catch((e) => log.error(e)); } else { throw new Error("The first message sent MUST be of type JoinRoomMessage"); } @@ -246,13 +247,13 @@ const roomManager: IRoomManagerServer = { }); call.on("error", (err: Error) => { - console.error("An error occurred in joinAdminRoom stream:", err); + log.error("An error occurred in joinAdminRoom stream:", err); }); }, sendAdminMessage(call: ServerUnaryCall, callback: sendUnaryData): void { socketManager .sendAdminMessage(call.request.getRoomid(), call.request.getRecipientuuid(), call.request.getMessage()) - .catch((e) => console.error(e)); + .catch((e) => log.error(e)); callback(null, new EmptyMessage()); }, @@ -265,7 +266,7 @@ const roomManager: IRoomManagerServer = { // FIXME Work in progress socketManager .banUser(call.request.getRoomid(), call.request.getRecipientuuid(), call.request.getMessage()) - .catch((e) => console.error(e)); + .catch((e) => log.error(e)); callback(null, new EmptyMessage()); }, @@ -273,7 +274,7 @@ const roomManager: IRoomManagerServer = { // FIXME: we could improve return message by returning a Success|ErrorMessage message socketManager .sendAdminRoomMessage(call.request.getRoomid(), call.request.getMessage(), call.request.getType()) - .catch((e) => console.error(e)); + .catch((e) => log.error(e)); callback(null, new EmptyMessage()); }, sendWorldFullWarningToRoom( @@ -281,7 +282,7 @@ const roomManager: IRoomManagerServer = { callback: sendUnaryData ): void { // FIXME: we could improve return message by returning a Success|ErrorMessage message - socketManager.dispatchWorldFullWarning(call.request.getRoomid()).catch((e) => console.error(e)); + socketManager.dispatchWorldFullWarning(call.request.getRoomid()).catch((e) => log.error(e)); callback(null, new EmptyMessage()); }, sendRefreshRoomPrompt( @@ -289,7 +290,7 @@ const roomManager: IRoomManagerServer = { callback: sendUnaryData ): void { // FIXME: we could improve return message by returning a Success|ErrorMessage message - socketManager.dispatchRoomRefresh(call.request.getRoomid()).catch((e) => console.error(e)); + socketManager.dispatchRoomRefresh(call.request.getRoomid()).catch((e) => log.error(e)); callback(null, new EmptyMessage()); }, }; diff --git a/back/src/Server/server/formdata.ts b/back/src/Server/server/formdata.ts index 0e17de78..a3ef07ee 100644 --- a/back/src/Server/server/formdata.ts +++ b/back/src/Server/server/formdata.ts @@ -2,6 +2,7 @@ import { createWriteStream } from "fs"; import { join, dirname } from "path"; import Busboy from "busboy"; import mkdirp from "mkdirp"; +import log from "../../Services/Logger"; function formData( contType: string, @@ -19,7 +20,7 @@ function formData( filename?: (oldName: string) => string; } = {} ) { - console.log("Enter form data"); + log.info("Enter form data"); options.headers = { "content-type": contType, }; diff --git a/back/src/Services/CpuTracker.ts b/back/src/Services/CpuTracker.ts index 3d06ca70..4ff48eb6 100644 --- a/back/src/Services/CpuTracker.ts +++ b/back/src/Services/CpuTracker.ts @@ -1,4 +1,5 @@ import { CPU_OVERHEAT_THRESHOLD } from "../Enum/EnvironmentVariable"; +import log from "./Logger"; function secNSec2ms(secNSec: Array | number) { if (Array.isArray(secNSec)) { @@ -28,16 +29,16 @@ class CpuTracker { if (!this.overHeating && this.cpuPercent > CPU_OVERHEAT_THRESHOLD) { this.overHeating = true; - console.warn('CPU high threshold alert. Going in "overheat" mode'); + log.warn('CPU high threshold alert. Going in "overheat" mode'); } else if (this.overHeating && this.cpuPercent <= CPU_OVERHEAT_THRESHOLD) { this.overHeating = false; - console.log('CPU is back to normal. Canceling "overheat" mode'); + log.info('CPU is back to normal. Canceling "overheat" mode'); } - /*console.log('elapsed time ms: ', elapTimeMS) - console.log('elapsed user ms: ', elapUserMS) - console.log('elapsed system ms:', elapSystMS) - console.log('cpu percent: ', this.cpuPercent)*/ + /*log.info('elapsed time ms: ', elapTimeMS) + log.info('elapsed user ms: ', elapUserMS) + log.info('elapsed system ms:', elapSystMS) + log.info('cpu percent: ', this.cpuPercent)*/ }, 100); } diff --git a/back/src/Services/Logger.ts b/back/src/Services/Logger.ts new file mode 100644 index 00000000..e19f60d1 --- /dev/null +++ b/back/src/Services/Logger.ts @@ -0,0 +1,16 @@ +import * as winston from "winston"; + +const logger = winston.createLogger({ + transports: [ + new winston.transports.Console({ + format: winston.format.combine( + winston.format.colorize(), + winston.format.timestamp(), + winston.format.align(), + winston.format.printf((info) => `${info.timestamp} ${info.level}: ${info.message}`) + ), + }), + ], +}); + +export default logger; diff --git a/back/src/Services/MapFetcher.ts b/back/src/Services/MapFetcher.ts index a17f722a..5d8bb9ef 100644 --- a/back/src/Services/MapFetcher.ts +++ b/back/src/Services/MapFetcher.ts @@ -5,6 +5,7 @@ import { promisify } from "util"; import { LocalUrlError } from "./LocalUrlError"; import { ITiledMap } from "@workadventure/tiled-map-type-guard"; import { isTiledMap } from "@workadventure/tiled-map-type-guard/dist"; +import log from "./Logger"; class MapFetcher { async fetchMap(mapUrl: string): Promise { @@ -29,7 +30,7 @@ class MapFetcher { if (!isTiledMap(res.data)) { //TODO fixme //throw new Error("Invalid map format for map " + mapUrl); - console.error("Invalid map format for map " + mapUrl); + log.error("Invalid map format for map " + mapUrl); } return res.data; diff --git a/back/src/Services/MessageHelpers.ts b/back/src/Services/MessageHelpers.ts index 606374be..9068881c 100644 --- a/back/src/Services/MessageHelpers.ts +++ b/back/src/Services/MessageHelpers.ts @@ -9,6 +9,7 @@ import { } from "../Messages/generated/messages_pb"; import { UserSocket } from "_Model/User"; import { RoomSocket, ZoneSocket } from "../RoomManager"; +import log from "./Logger"; export function emitError(Client: UserSocket, message: string): void { const errorMessage = new ErrorMessage(); @@ -20,11 +21,11 @@ export function emitError(Client: UserSocket, message: string): void { //if (!Client.disconnecting) { Client.write(serverToClientMessage); //} - console.warn(message); + log.warn(message); } export function emitErrorOnRoomSocket(Client: RoomSocket, message: string): void { - console.error(message); + log.error(message); const errorMessage = new ErrorMessage(); errorMessage.setMessage(message); @@ -38,11 +39,11 @@ export function emitErrorOnRoomSocket(Client: RoomSocket, message: string): void //if (!Client.disconnecting) { Client.write(batchToPusherMessage); //} - console.warn(message); + log.warn(message); } export function emitErrorOnZoneSocket(Client: ZoneSocket, message: string): void { - console.error(message); + log.error(message); const errorMessage = new ErrorMessage(); errorMessage.setMessage(message); @@ -56,5 +57,5 @@ export function emitErrorOnZoneSocket(Client: ZoneSocket, message: string): void //if (!Client.disconnecting) { Client.write(batchToPusherMessage); //} - console.warn(message); + log.warn(message); } diff --git a/back/src/Services/RedisClient.ts b/back/src/Services/RedisClient.ts index 1f8c1ecd..4737f21e 100644 --- a/back/src/Services/RedisClient.ts +++ b/back/src/Services/RedisClient.ts @@ -1,5 +1,6 @@ import { ClientOpts, createClient, RedisClient } from "redis"; import { REDIS_HOST, REDIS_PASSWORD, REDIS_PORT } from "../Enum/EnvironmentVariable"; +import log from "./Logger"; let redisClient: RedisClient | null = null; @@ -16,7 +17,7 @@ if (REDIS_HOST !== undefined) { redisClient = createClient(config); redisClient.on("error", (err) => { - console.error("Error connecting to Redis:", err); + log.error("Error connecting to Redis:", err); }); } diff --git a/back/src/Services/Repository/VariablesRepository.ts b/back/src/Services/Repository/VariablesRepository.ts index 9f668bcf..89bac288 100644 --- a/back/src/Services/Repository/VariablesRepository.ts +++ b/back/src/Services/Repository/VariablesRepository.ts @@ -2,10 +2,11 @@ import { RedisVariablesRepository } from "./RedisVariablesRepository"; import { redisClient } from "../RedisClient"; import { VoidVariablesRepository } from "./VoidVariablesRepository"; import { VariablesRepositoryInterface } from "./VariablesRepositoryInterface"; +import log from "../../Services/Logger"; let variablesRepository: VariablesRepositoryInterface; if (!redisClient) { - console.warn("WARNING: Redis isnot configured. No variables will be persisted."); + log.warn("WARNING: Redis isnot configured. No variables will be persisted."); variablesRepository = new VoidVariablesRepository(); } else { variablesRepository = new RedisVariablesRepository(redisClient); diff --git a/back/src/Services/SocketManager.ts b/back/src/Services/SocketManager.ts index 3e8baf61..910dc26a 100644 --- a/back/src/Services/SocketManager.ts +++ b/back/src/Services/SocketManager.ts @@ -56,6 +56,7 @@ import { Zone } from "_Model/Zone"; import Debug from "debug"; import { Admin } from "_Model/Admin"; import crypto from "crypto"; +import log from "./Logger"; const debug = Debug("sockermanager"); @@ -89,7 +90,7 @@ export class SocketManager { const { room, user } = await this.joinRoom(socket, joinRoomMessage); if (!socket.writable) { - console.warn("Socket was aborted"); + log.warn("Socket was aborted"); return { room, user, @@ -156,7 +157,7 @@ export class SocketManager { name: playerDetailsMessage.getName(), characterLayers: playerDetailsMessage.getCharacterlayersList() }; - //console.log(SocketIoEvent.SET_PLAYER_DETAILS, playerDetails); + //log.info(SocketIoEvent.SET_PLAYER_DETAILS, playerDetails); if (!isSetPlayerDetailsMessage(playerDetails)) { emitError(client, 'Invalid SET_PLAYER_DETAILS message received: '); return; @@ -192,7 +193,7 @@ export class SocketManager { //send only at user const remoteUser = room.getUsers().get(data.getReceiverid()); if (remoteUser === undefined) { - console.warn( + log.warn( "While exchanging a WebRTC signal: client with id ", data.getReceiverid(), " does not exist. This might be a race condition." @@ -222,7 +223,7 @@ export class SocketManager { //send only at user const remoteUser = room.getUsers().get(data.getReceiverid()); if (remoteUser === undefined) { - console.warn( + log.warn( "While exchanging a WEBRTC_SCREEN_SHARING signal: client with id ", data.getReceiverid(), " does not exist. This might be a race condition." @@ -260,7 +261,7 @@ export class SocketManager { } } finally { clientEventsEmitter.emitClientLeave(user.uuid, room.roomUrl); - console.log("A user left"); + log.info("A user left"); } } @@ -308,7 +309,7 @@ export class SocketManager { const user = room.join(socket, joinRoomMessage); clientEventsEmitter.emitClientJoin(user.uuid, roomId); - console.log(new Date().toISOString() + " user '"+user.uuid+"' joined room '"+roomId+"'"); + log.info(new Date().toISOString() + " user '" + user.uuid + "' joined room '" + roomId + "'"); return { room, user }; } @@ -337,7 +338,7 @@ export class SocketManager { } else if (thing instanceof Group) { this.emitCreateUpdateGroupEvent(listener, fromZone, thing); } else { - console.error("Unexpected type for Movable."); + log.error("Unexpected type for Movable."); } } @@ -352,11 +353,11 @@ export class SocketManager { emitZoneMessage(subMessage, listener); //listener.emitInBatch(subMessage); - //console.log("Sending USER_MOVED event"); + //log.info("Sending USER_MOVED event"); } else if (thing instanceof Group) { this.emitCreateUpdateGroupEvent(listener, null, thing); } else { - console.error("Unexpected type for Movable."); + log.error("Unexpected type for Movable."); } } @@ -366,7 +367,7 @@ export class SocketManager { } else if (thing instanceof Group) { this.emitDeleteGroupEvent(listener, thing.getId(), newZone); } else { - console.error("Unexpected type for Movable."); + log.error("Unexpected type for Movable."); } } @@ -635,7 +636,7 @@ export class SocketManager { batchMessage.addPayload(subMessage); } else { - console.error("Unexpected type for Movable returned by setViewport"); + log.error("Unexpected type for Movable returned by setViewport"); } } @@ -693,7 +694,7 @@ export class SocketManager { public async sendAdminMessage(roomId: string, recipientUuid: string, message: string): Promise { const room = await this.roomsPromises.get(roomId); if (!room) { - console.error( + log.error( "In sendAdminMessage, could not find room with id '" + roomId + "'. Maybe the room was closed a few milliseconds ago and there was a race condition?" @@ -703,7 +704,7 @@ export class SocketManager { const recipients = room.getUsersByUuid(recipientUuid); if (recipients.length === 0) { - console.error( + log.error( "In sendAdminMessage, could not find user with id '" + recipientUuid + "'. Maybe the user left the room a few milliseconds ago and there was a race condition?" @@ -726,7 +727,7 @@ export class SocketManager { public async banUser(roomId: string, recipientUuid: string, message: string): Promise { const room = await this.roomsPromises.get(roomId); if (!room) { - console.error( + log.error( "In banUser, could not find room with id '" + roomId + "'. Maybe the room was closed a few milliseconds ago and there was a race condition?" @@ -736,7 +737,7 @@ export class SocketManager { const recipients = room.getUsersByUuid(recipientUuid); if (recipients.length === 0) { - console.error( + log.error( "In banUser, could not find user with id '" + recipientUuid + "'. Maybe the user left the room a few milliseconds ago and there was a race condition?" @@ -765,7 +766,7 @@ export class SocketManager { const room = await this.roomsPromises.get(roomId); if (!room) { //todo: this should cause the http call to return a 500 - console.error( + log.error( "In sendAdminRoomMessage, could not find room with id '" + roomId + "'. Maybe the room was closed a few milliseconds ago and there was a race condition?" @@ -789,7 +790,7 @@ export class SocketManager { const room = await this.roomsPromises.get(roomId); if (!room) { //todo: this should cause the http call to return a 500 - console.error( + log.error( "In dispatchWorldFullWarning, could not find room with id '" + roomId + "'. Maybe the room was closed a few milliseconds ago and there was a race condition?" diff --git a/back/src/Services/VariablesManager.ts b/back/src/Services/VariablesManager.ts index 915c6c05..1759a117 100644 --- a/back/src/Services/VariablesManager.ts +++ b/back/src/Services/VariablesManager.ts @@ -10,6 +10,7 @@ import { import { User } from "_Model/User"; import { variablesRepository } from "./Repository/VariablesRepository"; import { redisClient } from "./RedisClient"; +import log from "./Logger"; interface Variable { defaultValue?: string; @@ -98,7 +99,7 @@ export class VariablesManager { for (const object of layer.objects) { if (object.type === "variable") { if (object.template) { - console.warn( + log.warn( 'Warning, a variable object is using a Tiled "template". WorkAdventure does not support objects generated from Tiled templates.' ); continue; @@ -204,7 +205,7 @@ export class VariablesManager { if (variableObject !== undefined && variableObject.persist) { variablesRepository .saveVariable(this.roomUrl, name, value) - .catch((e) => console.error("Error while saving variable in Redis:", e)); + .catch((e) => log.error("Error while saving variable in Redis:", e)); } return readableBy; diff --git a/back/tsconfig.json b/back/tsconfig.json index e149d304..cb55d5c1 100644 --- a/back/tsconfig.json +++ b/back/tsconfig.json @@ -46,7 +46,7 @@ "paths": { "_Controller/*": ["src/Controller/*"], "_Model/*": ["src/Model/*"], - "_Enum/*": ["src/Enum/*"] + "_Enum/*": ["src/Enum/*"], }, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ // "typeRoots": [], /* List of folders to include type definitions from. */ diff --git a/back/yarn.lock b/back/yarn.lock index ff9cb180..9946289c 100644 --- a/back/yarn.lock +++ b/back/yarn.lock @@ -23,6 +23,15 @@ chalk "^2.0.0" js-tokens "^4.0.0" +"@dabh/diagnostics@^2.0.2": + version "2.0.2" + resolved "https://registry.yarnpkg.com/@dabh/diagnostics/-/diagnostics-2.0.2.tgz#290d08f7b381b8f94607dc8f471a12c675f9db31" + integrity sha512-+A1YivoVDNNVCdfozHSR8v/jyuuLTMXwjWuxPFlFlUapXoGc+Gj9mDlTDDfrwl7rXCl2tNZ0kE8sIBO6YOn96Q== + dependencies: + colorspace "1.1.x" + enabled "2.0.x" + kuler "^2.0.0" + "@mrmlnc/readdir-enhanced@^2.2.1": version "2.2.1" resolved "https://registry.yarnpkg.com/@mrmlnc/readdir-enhanced/-/readdir-enhanced-2.2.1.tgz#524af240d1a360527b730475ecfa1344aa540dde" @@ -376,6 +385,11 @@ astral-regex@^2.0.0: resolved "https://registry.yarnpkg.com/astral-regex/-/astral-regex-2.0.0.tgz#483143c567aeed4785759c0865786dc77d7d2e31" integrity sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ== +async@^3.1.0: + version "3.2.2" + resolved "https://registry.yarnpkg.com/async/-/async-3.2.2.tgz#2eb7671034bb2194d45d30e31e24ec7e7f9670cd" + integrity sha512-H0E+qZaDEfx/FY4t7iLRv1W2fFI6+pyCeTw1uN20AQPiwqwM6ojPxHxdLv4z8hi2DtnW9BOckSspLucW7pIE5g== + atob@^2.1.2: version "2.1.2" resolved "https://registry.yarnpkg.com/atob/-/atob-2.1.2.tgz#6d9517eb9e030d2436666651e86bd9f6f13533c9" @@ -621,7 +635,7 @@ collection-visit@^1.0.0: map-visit "^1.0.0" object-visit "^1.0.0" -color-convert@^1.9.0: +color-convert@^1.9.0, color-convert@^1.9.3: version "1.9.3" resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" integrity sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg== @@ -640,16 +654,45 @@ color-name@1.1.3: resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" integrity sha1-p9BVi9icQveV3UIyj3QIMcpTvCU= -color-name@~1.1.4: +color-name@^1.0.0, color-name@~1.1.4: version "1.1.4" resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== +color-string@^1.6.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/color-string/-/color-string-1.6.0.tgz#c3915f61fe267672cb7e1e064c9d692219f6c312" + integrity sha512-c/hGS+kRWJutUBEngKKmk4iH3sD59MBkoxVapS/0wgpCz2u7XsNloxknyvBhzwEs1IbV36D9PwqLPJ2DTu3vMA== + dependencies: + color-name "^1.0.0" + simple-swizzle "^0.2.2" + +color@^3.1.3: + version "3.2.1" + resolved "https://registry.yarnpkg.com/color/-/color-3.2.1.tgz#3544dc198caf4490c3ecc9a790b54fe9ff45e164" + integrity sha512-aBl7dZI9ENN6fUGC7mWpMTPNHmWUSNan9tuWN6ahh5ZLNk9baLJOnSMlrQkHcrfFgz2/RigjUVAjdx36VcemKA== + dependencies: + color-convert "^1.9.3" + color-string "^1.6.0" + colorette@^1.2.2: version "1.2.2" resolved "https://registry.yarnpkg.com/colorette/-/colorette-1.2.2.tgz#cbcc79d5e99caea2dbf10eb3a26fd8b3e6acfa94" integrity sha512-MKGMzyfeuutC/ZJ1cba9NqcNpfeqMUcYmyF1ZFY6/Cn7CNSAKx6a+s48sqLqyAiZuaP2TcqMhoo+dlwFnVxT9w== +colors@^1.2.1: + version "1.4.0" + resolved "https://registry.yarnpkg.com/colors/-/colors-1.4.0.tgz#c50491479d4c1bdaed2c9ced32cf7c7dc2360f78" + integrity sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA== + +colorspace@1.1.x: + version "1.1.4" + resolved "https://registry.yarnpkg.com/colorspace/-/colorspace-1.1.4.tgz#8d442d1186152f60453bf8070cd66eb364e59243" + integrity sha512-BgvKJiuVu1igBUF2kEjRCZXol6wiiGbY5ipL/oVPwm0BL9sIpMIzM8IK7vwuxIIzOXMV3Ey5w+vxhm0rR/TN8w== + dependencies: + color "^3.1.3" + text-hex "1.0.x" + colour@~0.7.1: version "0.7.1" resolved "https://registry.yarnpkg.com/colour/-/colour-0.7.1.tgz#9cb169917ec5d12c0736d3e8685746df1cadf778" @@ -864,6 +907,11 @@ emoji-regex@^8.0.0: resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== +enabled@2.0.x: + version "2.0.0" + resolved "https://registry.yarnpkg.com/enabled/-/enabled-2.0.0.tgz#f9dd92ec2d6f4bbc0d5d1e64e21d61cd4665e7c2" + integrity sha512-AKrN98kuwOzMIdAizXGI86UFBoo26CL21UM763y1h/GMSJ4/OHU9k2YlsmBpyScFo/wbLzWQJBMCW4+IO3/+OQ== + enquirer@^2.3.6: version "2.3.6" resolved "https://registry.yarnpkg.com/enquirer/-/enquirer-2.3.6.tgz#2a7fe5dd634a1e4125a975ec994ff5456dc3734d" @@ -1089,6 +1137,11 @@ fast-levenshtein@~2.0.6: resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917" integrity sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc= +fecha@^4.2.0: + version "4.2.1" + resolved "https://registry.yarnpkg.com/fecha/-/fecha-4.2.1.tgz#0a83ad8f86ef62a091e22bb5a039cd03d23eecce" + integrity sha512-MMMQ0ludy/nBs1/o0zVOiKTpG7qMbonKUzjJgQFEuvq6INZ1OraKPRAWkBq5vlKLOUMpmNYG1JoN3oDPUQ9m3Q== + figures@^3.0.0: version "3.2.0" resolved "https://registry.yarnpkg.com/figures/-/figures-3.2.0.tgz#625c18bd293c604dc4a8ddb2febf0c88341746af" @@ -1142,6 +1195,11 @@ flatted@^2.0.0: resolved "https://registry.yarnpkg.com/flatted/-/flatted-2.0.2.tgz#4575b21e2bcee7434aa9be662f4b7b5f9c2b5138" integrity sha512-r5wGx7YeOwNWNlCA0wQ86zKyDLMQr+/RB8xy74M4hTphfmjlijTSSXGuH8rnvKZnfT9i+75zmd8jcKdMR4O6jA== +fn.name@1.x.x: + version "1.1.0" + resolved "https://registry.yarnpkg.com/fn.name/-/fn.name-1.1.0.tgz#26cad8017967aea8731bc42961d04a3d5988accc" + integrity sha512-GRnmB5gPyJpAhTQdSZTSp9uaPSvl09KoYcMQtsB9rQoOmzs9dH6ffeccH+Z+cv6P68Hu5bC6JjRh4Ah/mHSNRw== + follow-redirects@^1.14.0: version "1.14.4" resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.4.tgz#838fdf48a8bbdd79e52ee51fb1c94e3ed98b9379" @@ -1407,7 +1465,7 @@ inflight@^1.0.4: once "^1.3.0" wrappy "1" -inherits@2, inherits@~2.0.3: +inherits@2, inherits@^2.0.3, inherits@~2.0.3: version "2.0.4" resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== @@ -1465,6 +1523,11 @@ is-arrayish@^0.2.1: resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d" integrity sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0= +is-arrayish@^0.3.1: + version "0.3.2" + resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.3.2.tgz#4574a2ae56f7ab206896fb431eaeed066fdf8f03" + integrity sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ== + is-binary-path@~2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-2.1.0.tgz#ea1f7f3b80f064236e83470f86c09c254fb45b09" @@ -1731,6 +1794,11 @@ kind-of@^6.0.0, kind-of@^6.0.2: resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.3.tgz#07c05034a6c349fa06e24fa35aa76db4580ce4dd" integrity sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw== +kuler@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/kuler/-/kuler-2.0.0.tgz#e2c570a3800388fb44407e851531c1d670b061b3" + integrity sha512-Xq9nH7KlWZmXAtodXDDRE7vs6DU1gTU8zYDHDiWLSip45Egwq3plLHzPn27NgvzL2r1LMPC1vdqh98sQxtqj4A== + lcid@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/lcid/-/lcid-1.0.0.tgz#308accafa0bc483a3867b4b6f2b9506251d1b835" @@ -1864,6 +1932,17 @@ log-update@^4.0.0: slice-ansi "^4.0.0" wrap-ansi "^6.2.0" +logform@^2.2.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/logform/-/logform-2.3.0.tgz#a3997a05985de2ebd325ae0d166dffc9c6fe6b57" + integrity sha512-graeoWUH2knKbGthMtuG1EfaSPMZFZBIrhuJHhkS5ZseFBrc7DupCzihOQAzsK/qIKPQaPJ/lFQFctILUY5ARQ== + dependencies: + colors "^1.2.1" + fecha "^4.2.0" + ms "^2.1.1" + safe-stable-stringify "^1.1.0" + triple-beam "^1.3.0" + long@~3: version "3.2.0" resolved "https://registry.yarnpkg.com/long/-/long-3.2.0.tgz#d821b7138ca1cb581c172990ef14db200b5c474b" @@ -2177,6 +2256,13 @@ once@^1.3.0: dependencies: wrappy "1" +one-time@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/one-time/-/one-time-1.0.0.tgz#e06bc174aed214ed58edede573b433bbf827cb45" + integrity sha512-5DXOiRKwuSEcQ/l0kGCF6Q3jcADFv5tSmRaJck/OqkVFcOzutB134KRSfF0xDrL39MNnqxbHBbUUcjZIhTgb2g== + dependencies: + fn.name "1.x.x" + onetime@^5.1.0, onetime@^5.1.2: version "5.1.2" resolved "https://registry.yarnpkg.com/onetime/-/onetime-5.1.2.tgz#d0e96ebb56b07476df1dd9c4806e5237985ca45e" @@ -2425,7 +2511,7 @@ read-pkg@^1.0.0: normalize-package-data "^2.3.2" path-type "^1.0.0" -readable-stream@^2.0.6: +readable-stream@^2.0.6, readable-stream@^2.3.7: version "2.3.7" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.7.tgz#1eca1cf711aef814c04f62252a36a62f6cb23b57" integrity sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw== @@ -2438,6 +2524,15 @@ readable-stream@^2.0.6: string_decoder "~1.1.1" util-deprecate "~1.0.1" +readable-stream@^3.4.0: + version "3.6.0" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.6.0.tgz#337bbda3adc0706bd3e024426a286d4b4b2c9198" + integrity sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA== + dependencies: + inherits "^2.0.3" + string_decoder "^1.1.1" + util-deprecate "^1.0.1" + readdirp@~3.4.0: version "3.4.0" resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.4.0.tgz#9fdccdf9e9155805449221ac645e8303ab5b9ada" @@ -2578,7 +2673,7 @@ rxjs@^6.6.7: dependencies: tslib "^1.9.0" -safe-buffer@^5.0.1, safe-buffer@^5.1.2, safe-buffer@^5.2.1: +safe-buffer@^5.0.1, safe-buffer@^5.1.2, safe-buffer@^5.2.1, safe-buffer@~5.2.0: version "5.2.1" resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== @@ -2595,6 +2690,11 @@ safe-regex@^1.1.0: dependencies: ret "~0.1.10" +safe-stable-stringify@^1.1.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/safe-stable-stringify/-/safe-stable-stringify-1.1.1.tgz#c8a220ab525cd94e60ebf47ddc404d610dc5d84a" + integrity sha512-ERq4hUjKDbJfE4+XtZLFPCDi8Vb1JqaxAPTxWFLBx8XcAlf9Bda/ZJdVezs/NAfsMQScyIlUMx+Yeu7P7rx5jw== + "safer-buffer@>= 2.1.2 < 3": version "2.1.2" resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" @@ -2669,6 +2769,13 @@ signal-exit@^3.0.0, signal-exit@^3.0.2, signal-exit@^3.0.3: resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.3.tgz#a1410c2edd8f077b08b4e253c8eacfcaf057461c" integrity sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA== +simple-swizzle@^0.2.2: + version "0.2.2" + resolved "https://registry.yarnpkg.com/simple-swizzle/-/simple-swizzle-0.2.2.tgz#a4da6b635ffcccca33f70d17cb92592de95e557a" + integrity sha1-pNprY1/8zMoz9w0Xy5JZLeleVXo= + dependencies: + is-arrayish "^0.3.1" + slice-ansi@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-2.1.0.tgz#cacd7693461a637a5788d92a7dd4fba068e81636" @@ -2803,6 +2910,11 @@ sprintf-js@~1.0.2: resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw= +stack-trace@0.0.x: + version "0.0.10" + resolved "https://registry.yarnpkg.com/stack-trace/-/stack-trace-0.0.10.tgz#547c70b347e8d32b4e108ea1a2a159e5fdde19c0" + integrity sha1-VHxws0fo0ytOEI6hoqFZ5f3eGcA= + static-extend@^0.1.1: version "0.1.2" resolved "https://registry.yarnpkg.com/static-extend/-/static-extend-0.1.2.tgz#60809c39cbff55337226fd5e0b520f341f1fb5c6" @@ -2870,6 +2982,13 @@ string-width@^4.2.0: is-fullwidth-code-point "^3.0.0" strip-ansi "^6.0.0" +string_decoder@^1.1.1: + version "1.3.0" + resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.3.0.tgz#42f114594a46cf1a8e30b0a84f56c78c3edac21e" + integrity sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA== + dependencies: + safe-buffer "~5.2.0" + string_decoder@~1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.1.1.tgz#9cf1611ba62685d7030ae9e4ba34149c3af03fc8" @@ -2992,6 +3111,11 @@ tdigest@^0.1.1: dependencies: bintrees "1.0.1" +text-hex@1.0.x: + version "1.0.0" + resolved "https://registry.yarnpkg.com/text-hex/-/text-hex-1.0.0.tgz#69dc9c1b17446ee79a92bf5b884bb4b9127506f5" + integrity sha512-uuVGNWzgJ4yhRaNSiubPY7OjISw4sw4E5Uv0wbjp+OzcbmVU/rsT8ujgcXJhn9ypzsgr5vlzpPqP+MBBKcGvbg== + text-table@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" @@ -3051,6 +3175,11 @@ trim-newlines@^1.0.0: resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-1.0.0.tgz#5887966bb582a4503a41eb524f7d35011815a613" integrity sha1-WIeWa7WCpFA6QetST301ARgVphM= +triple-beam@^1.2.0, triple-beam@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/triple-beam/-/triple-beam-1.3.0.tgz#a595214c7298db8339eeeee083e4d10bd8cb8dd9" + integrity sha512-XrHUvV5HpdLmIj4uVMxHggLbFSZYIn7HEWsqePZcI50pco+MPqJ50wMGY794X7AOOhxOBAjbkqfAbEe/QMp2Lw== + ts-node-dev@^1.0.0-pre.44: version "1.0.0-pre.63" resolved "https://registry.yarnpkg.com/ts-node-dev/-/ts-node-dev-1.0.0-pre.63.tgz#0e69df26cef35a728362d93348f13caa2cb2c512" @@ -3167,7 +3296,7 @@ use@^3.1.0: resolved "https://registry.yarnpkg.com/use/-/use-3.1.1.tgz#d50c8cac79a19fbc20f2911f56eb973f4e10070f" integrity sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ== -util-deprecate@~1.0.1: +util-deprecate@^1.0.1, util-deprecate@~1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" integrity sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8= @@ -3224,6 +3353,29 @@ window-size@^0.1.4: resolved "https://registry.yarnpkg.com/window-size/-/window-size-0.1.4.tgz#f8e1aa1ee5a53ec5bf151ffa09742a6ad7697876" integrity sha1-+OGqHuWlPsW/FR/6CXQqatdpeHY= +winston-transport@^4.4.0: + version "4.4.0" + resolved "https://registry.yarnpkg.com/winston-transport/-/winston-transport-4.4.0.tgz#17af518daa690d5b2ecccaa7acf7b20ca7925e59" + integrity sha512-Lc7/p3GtqtqPBYYtS6KCN3c77/2QCev51DvcJKbkFPQNoj1sinkGwLGFDxkXY9J6p9+EPnYs+D90uwbnaiURTw== + dependencies: + readable-stream "^2.3.7" + triple-beam "^1.2.0" + +winston@^3.3.3: + version "3.3.3" + resolved "https://registry.yarnpkg.com/winston/-/winston-3.3.3.tgz#ae6172042cafb29786afa3d09c8ff833ab7c9170" + integrity sha512-oEXTISQnC8VlSAKf1KYSSd7J6IWuRPQqDdo8eoRNaYKLvwSb5+79Z3Yi1lrl6KDpU6/VWaxpakDAtb1oQ4n9aw== + dependencies: + "@dabh/diagnostics" "^2.0.2" + async "^3.1.0" + is-stream "^2.0.0" + logform "^2.2.0" + one-time "^1.0.0" + readable-stream "^3.4.0" + stack-trace "0.0.x" + triple-beam "^1.3.0" + winston-transport "^4.4.0" + word-wrap@~1.2.3: version "1.2.3" resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.3.tgz#610636f6b1f703891bd34771ccb17fb93b47079c" diff --git a/package.json b/package.json index 038edf2c..ff6c2a33 100644 --- a/package.json +++ b/package.json @@ -4,5 +4,6 @@ }, "scripts": { "prepare": "husky install" - } + }, + "dependencies": {} } diff --git a/yarn.lock b/yarn.lock index b9698f61..adbed748 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,6 +2,7 @@ # yarn lockfile v1 -"husky@^6.0.0": - "resolved" "https://registry.npmjs.org/husky/-/husky-6.0.0.tgz" - "version" "6.0.0" +husky@^7.0.1: + version "7.0.4" + resolved "https://registry.yarnpkg.com/husky/-/husky-7.0.4.tgz#242048245dc49c8fb1bf0cc7cfb98dd722531535" + integrity sha512-vbaCKN2QLtP/vD4yvs6iz6hBEo6wkSzs8HpRah1Z6aGmF2KW5PdYuAd7uX5a+OyBZHBhd+TFLqgjUgytQr4RvQ== From dd89f12c2ecd4b15de75ea9c238d44ab47141785 Mon Sep 17 00:00:00 2001 From: Alexis Faizeau Date: Mon, 8 Nov 2021 19:05:25 +0100 Subject: [PATCH 04/18] Implement logger on pusher --- pusher/package.json | 3 +- pusher/server.ts | 4 +- pusher/src/Controller/AdminController.ts | 9 +- .../src/Controller/AuthenticateController.ts | 25 +-- pusher/src/Controller/BaseController.ts | 7 +- pusher/src/Controller/IoSocketController.ts | 27 +-- pusher/src/Controller/MapController.ts | 7 +- pusher/src/Model/PositionDispatcher.ts | 3 +- pusher/src/Model/Zone.ts | 3 +- pusher/src/Server/server/formdata.ts | 3 +- pusher/src/Services/CpuTracker.ts | 13 +- pusher/src/Services/IoSocketHelpers.ts | 3 +- pusher/src/Services/Logger.ts | 16 ++ pusher/src/Services/SocketManager.ts | 48 +++-- pusher/yarn.lock | 164 +++++++++++++++++- 15 files changed, 263 insertions(+), 72 deletions(-) create mode 100644 pusher/src/Services/Logger.ts diff --git a/pusher/package.json b/pusher/package.json index dacbfd72..a51d51f4 100644 --- a/pusher/package.json +++ b/pusher/package.json @@ -53,7 +53,8 @@ "prom-client": "^12.0.0", "query-string": "^6.13.3", "uWebSockets.js": "uNetworking/uWebSockets.js#v18.5.0", - "uuidv4": "^6.0.7" + "uuidv4": "^6.0.7", + "winston": "^3.3.3" }, "devDependencies": { "@types/busboy": "^0.2.3", diff --git a/pusher/server.ts b/pusher/server.ts index 40810d98..e567eb14 100644 --- a/pusher/server.ts +++ b/pusher/server.ts @@ -1,4 +1,6 @@ // lib/server.ts import App from "./src/App"; import { PUSHER_HTTP_PORT } from "./src/Enum/EnvironmentVariable"; -App.listen(PUSHER_HTTP_PORT, () => console.log(`WorkAdventure starting on port ${PUSHER_HTTP_PORT}!`)) +import log from "./src/Services/Logger"; + +App.listen(PUSHER_HTTP_PORT, () => log.info(`WorkAdventure starting on port ${PUSHER_HTTP_PORT}!`)); diff --git a/pusher/src/Controller/AdminController.ts b/pusher/src/Controller/AdminController.ts index ec1bd067..4f7166f7 100644 --- a/pusher/src/Controller/AdminController.ts +++ b/pusher/src/Controller/AdminController.ts @@ -7,6 +7,7 @@ import { WorldFullWarningToRoomMessage, RefreshRoomPromptMessage, } from "../Messages/generated/messages_pb"; +import log from "../Services/Logger"; export class AdminController extends BaseController { constructor(private App: TemplatedApp) { @@ -25,14 +26,14 @@ export class AdminController extends BaseController { // eslint-disable-next-line @typescript-eslint/no-misused-promises this.App.post("/room/refresh", async (res: HttpResponse, req: HttpRequest) => { res.onAborted(() => { - console.warn("/message request was aborted"); + log.warn("/message request was aborted"); }); const token = req.getHeader("admin-token"); const body = await res.json(); if (token !== ADMIN_API_TOKEN) { - console.error("Admin access refused for token: " + token); + log.error("Admin access refused for token: " + token); res.writeStatus("401 Unauthorized").end("Incorrect token"); return; } @@ -72,14 +73,14 @@ export class AdminController extends BaseController { // eslint-disable-next-line @typescript-eslint/no-misused-promises this.App.post("/message", async (res: HttpResponse, req: HttpRequest) => { res.onAborted(() => { - console.warn("/message request was aborted"); + log.warn("/message request was aborted"); }); const token = req.getHeader("admin-token"); const body = await res.json(); if (token !== ADMIN_API_TOKEN) { - console.error("Admin access refused for token: " + token); + log.error("Admin access refused for token: " + token); res.writeStatus("401 Unauthorized").end("Incorrect token"); return; } diff --git a/pusher/src/Controller/AuthenticateController.ts b/pusher/src/Controller/AuthenticateController.ts index 972cc102..27b04bbd 100644 --- a/pusher/src/Controller/AuthenticateController.ts +++ b/pusher/src/Controller/AuthenticateController.ts @@ -5,6 +5,7 @@ import { adminApi } from "../Services/AdminApi"; import { AuthTokenData, jwtTokenManager } from "../Services/JWTTokenManager"; import { parse } from "query-string"; import { openIDClient } from "../Services/OpenIDClient"; +import log from "../Services/Logger"; export interface TokenInterface { userUuid: string; @@ -24,7 +25,7 @@ export class AuthenticateController extends BaseController { //eslint-disable-next-line @typescript-eslint/no-misused-promises this.App.get("/login-screen", async (res: HttpResponse, req: HttpRequest) => { res.onAborted(() => { - console.warn("/message request was aborted"); + log.warn("/message request was aborted"); }); try { @@ -43,7 +44,7 @@ export class AuthenticateController extends BaseController { res.writeHeader("Location", loginUri); return res.end(); } catch (e) { - console.error("openIDLogin => e", e); + log.error("openIDLogin => e", e); return this.errorToResponse(e, res); } }); @@ -53,7 +54,7 @@ export class AuthenticateController extends BaseController { //eslint-disable-next-line @typescript-eslint/no-misused-promises this.App.get("/login-callback", async (res: HttpResponse, req: HttpRequest) => { res.onAborted(() => { - console.warn("/message request was aborted"); + log.warn("/message request was aborted"); }); const { code, nonce, token } = parse(req.getQuery()); try { @@ -69,7 +70,7 @@ export class AuthenticateController extends BaseController { this.addCorsHeaders(res); return res.end(JSON.stringify({ authToken: token })); } catch (err) { - console.info("User was not connected", err); + log.info("User was not connected", err); } } @@ -84,7 +85,7 @@ export class AuthenticateController extends BaseController { this.addCorsHeaders(res); return res.end(JSON.stringify({ authToken })); } catch (e) { - console.error("openIDCallback => ERROR", e); + log.error("openIDCallback => ERROR", e); return this.errorToResponse(e, res); } }); @@ -92,7 +93,7 @@ export class AuthenticateController extends BaseController { // eslint-disable-next-line @typescript-eslint/no-misused-promises this.App.get("/logout-callback", async (res: HttpResponse, req: HttpRequest) => { res.onAborted(() => { - console.warn("/message request was aborted"); + log.warn("/message request was aborted"); }); const { token } = parse(req.getQuery()); @@ -104,7 +105,7 @@ export class AuthenticateController extends BaseController { } await openIDClient.logoutUser(authTokenData.hydraAccessToken); } catch (error) { - console.error("openIDCallback => logout-callback", error); + log.error("openIDCallback => logout-callback", error); } finally { res.writeStatus("200"); this.addCorsHeaders(res); @@ -125,7 +126,7 @@ export class AuthenticateController extends BaseController { this.App.post("/register", (res: HttpResponse, req: HttpRequest) => { (async () => { res.onAborted(() => { - console.warn("Login request was aborted"); + log.warn("Login request was aborted"); }); const param = await res.json(); @@ -156,7 +157,7 @@ export class AuthenticateController extends BaseController { }) ); } catch (e) { - console.error("register => ERROR", e); + log.error("register => ERROR", e); this.errorToResponse(e, res); } })(); @@ -172,7 +173,7 @@ export class AuthenticateController extends BaseController { this.App.post("/anonymLogin", (res: HttpResponse, req: HttpRequest) => { res.onAborted(() => { - console.warn("Login request was aborted"); + log.warn("Login request was aborted"); }); const userUuid = v4(); @@ -194,7 +195,7 @@ export class AuthenticateController extends BaseController { // eslint-disable-next-line @typescript-eslint/no-misused-promises this.App.get("/profile-callback", async (res: HttpResponse, req: HttpRequest) => { res.onAborted(() => { - console.warn("/message request was aborted"); + log.warn("/message request was aborted"); }); const { userIdentify, token } = parse(req.getQuery()); try { @@ -218,7 +219,7 @@ export class AuthenticateController extends BaseController { } } } catch (error) { - console.error("profileCallback => ERROR", error); + log.error("profileCallback => ERROR", error); this.errorToResponse(error, res); } }); diff --git a/pusher/src/Controller/BaseController.ts b/pusher/src/Controller/BaseController.ts index a983333a..e918d9ea 100644 --- a/pusher/src/Controller/BaseController.ts +++ b/pusher/src/Controller/BaseController.ts @@ -1,4 +1,5 @@ import { HttpResponse } from "uWebSockets.js"; +import log from "../Services/Logger"; export class BaseController { protected addCorsHeaders(res: HttpResponse): void { @@ -19,12 +20,12 @@ export class BaseController { } else { url = ""; } - console.error("ERROR: " + e.message + url); + log.error("ERROR: " + e.message + url); } else if (typeof e === "string") { - console.error(e); + log.error(e); } if (e.stack) { - console.error(e.stack); + log.error(e.stack); } if (e.response) { res.writeStatus(e.response.status + " " + e.response.statusText); diff --git a/pusher/src/Controller/IoSocketController.ts b/pusher/src/Controller/IoSocketController.ts index 0466100c..f1f956bc 100644 --- a/pusher/src/Controller/IoSocketController.ts +++ b/pusher/src/Controller/IoSocketController.ts @@ -31,6 +31,7 @@ import { Zone } from "_Model/Zone"; import { ExAdminSocketInterface } from "_Model/Websocket/ExAdminSocketInterface"; import { v4 } from "uuid"; import { CharacterTexture } from "../Services/AdminApi/CharacterTexture"; +import log from "../Services/Logger"; export class IoSocketController { private nextUserId: number = 1; @@ -49,13 +50,13 @@ export class IoSocketController { const websocketExtensions = req.getHeader("sec-websocket-extensions"); const token = query.token; if (token !== ADMIN_API_TOKEN) { - console.log("Admin access refused for token: " + token); + log.info("Admin access refused for token: " + token); res.writeStatus("401 Unauthorized").end("Incorrect token"); return; } const roomId = query.roomId; if (typeof roomId !== "string") { - console.error("Received"); + log.error("Received"); res.writeStatus("400 Bad Request").end("Missing room id"); return; } @@ -63,7 +64,7 @@ export class IoSocketController { res.upgrade({ roomId }, websocketKey, websocketProtocol, websocketExtensions, context); }, open: (ws) => { - console.log("Admin socket connect for room: " + ws.roomId); + log.info("Admin socket connect for room: " + ws.roomId); ws.disconnecting = false; socketManager.handleAdminRoom(ws as ExAdminSocketInterface, ws.roomId as string); @@ -96,7 +97,7 @@ export class IoSocketController { } } } catch (err) { - console.error(err); + log.error(err); } }, close: (ws, code, message) => { @@ -105,8 +106,8 @@ export class IoSocketController { Client.disconnecting = true; socketManager.leaveAdminRoom(Client); } catch (e) { - console.error('An error occurred on admin "disconnect"'); - console.error(e); + log.error('An error occurred on admin "disconnect"'); + log.error(e); } }, }); @@ -198,7 +199,7 @@ export class IoSocketController { if (err?.response?.status == 404) { // If we get an HTTP 404, the token is invalid. Let's perform an anonymous login! - console.warn( + log.warn( 'Cannot find user with email "' + (userIdentifier || "anonymous") + '". Performing an anonymous login instead.' @@ -238,13 +239,13 @@ export class IoSocketController { throw new Error("Use the login URL to connect"); } } catch (e) { - console.log( + log.info( "access not granted for user " + (userIdentifier || "anonymous") + " and room " + roomId ); - console.error(e); + log.error(e); throw new Error("User cannot access this world"); } } @@ -254,7 +255,7 @@ export class IoSocketController { SocketManager.mergeCharacterLayersAndCustomTextures(characterLayers, memberTextures); if (upgradeAborted.aborted) { - console.log("Ouch! Client disconnected before we could upgrade it!"); + log.info("Ouch! Client disconnected before we could upgrade it!"); /* You must not upgrade now */ return; } @@ -395,7 +396,7 @@ export class IoSocketController { //let ok = ws.send(message, isBinary); }, drain: (ws) => { - console.log("WebSocket backpressure: " + ws.getBufferedAmount()); + log.info("WebSocket backpressure: " + ws.getBufferedAmount()); }, close: (ws, code, message) => { const Client = ws as ExSocketInterface; @@ -404,8 +405,8 @@ export class IoSocketController { //leave room socketManager.leaveRoom(Client); } catch (e) { - console.error('An error occurred on "disconnect"'); - console.error(e); + log.error('An error occurred on "disconnect"'); + log.error(e); } }, }); diff --git a/pusher/src/Controller/MapController.ts b/pusher/src/Controller/MapController.ts index f775b50c..c3ccbd05 100644 --- a/pusher/src/Controller/MapController.ts +++ b/pusher/src/Controller/MapController.ts @@ -8,6 +8,7 @@ import { MapDetailsData } from "../Services/AdminApi/MapDetailsData"; import { socketManager } from "../Services/SocketManager"; import { AuthTokenData, jwtTokenManager } from "../Services/JWTTokenManager"; import { v4 } from "uuid"; +import log from "../Services/Logger"; export class MapController extends BaseController { constructor(private App: TemplatedApp) { @@ -26,13 +27,13 @@ export class MapController extends BaseController { this.App.get("/map", (res: HttpResponse, req: HttpRequest) => { res.onAborted(() => { - console.warn("/map request was aborted"); + log.warn("/map request was aborted"); }); const query = parse(req.getQuery()); if (typeof query.playUri !== "string") { - console.error("Expected playUri parameter in /map endpoint"); + log.error("Expected playUri parameter in /map endpoint"); res.writeStatus("400 Bad request"); this.addCorsHeaders(res); res.end("Expected playUri parameter"); @@ -82,7 +83,7 @@ export class MapController extends BaseController { // Decode token, in this case we don't need to create new token. authTokenData = jwtTokenManager.verifyJWTToken(query.authToken as string, true); userId = authTokenData.identifier; - console.info("JWT expire, but decoded", userId); + log.info("JWT expire, but decoded", userId); } } const mapDetails = await adminApi.fetchMapDetails(query.playUri as string, userId); diff --git a/pusher/src/Model/PositionDispatcher.ts b/pusher/src/Model/PositionDispatcher.ts index f868cd2c..ec95eded 100644 --- a/pusher/src/Model/PositionDispatcher.ts +++ b/pusher/src/Model/PositionDispatcher.ts @@ -11,6 +11,7 @@ import { Zone, ZoneEventListener } from "./Zone"; import { ViewportInterface } from "_Model/Websocket/ViewportMessage"; import { ExSocketInterface } from "_Model/Websocket/ExSocketInterface"; +import log from "../Services/Logger"; //import Debug from "debug"; //const debug = Debug('positiondispatcher'); @@ -44,7 +45,7 @@ export class PositionDispatcher { */ public setViewport(socket: ExSocketInterface, viewport: ViewportInterface): void { if (viewport.left > viewport.right || viewport.top > viewport.bottom) { - console.warn("Invalid viewport received: ", viewport); + log.warn("Invalid viewport received: ", viewport); return; } diff --git a/pusher/src/Model/Zone.ts b/pusher/src/Model/Zone.ts index d5a6058f..07255da7 100644 --- a/pusher/src/Model/Zone.ts +++ b/pusher/src/Model/Zone.ts @@ -20,6 +20,7 @@ import { import { ClientReadableStream } from "grpc"; import { PositionDispatcher } from "_Model/PositionDispatcher"; import Debug from "debug"; +import log from "../Services/Logger"; const debug = Debug("zone"); @@ -209,7 +210,7 @@ export class Zone { const userDescriptor = this.users.get(userId); if (userDescriptor === undefined) { - console.error('Unexpected move message received for user "' + userId + '"'); + log.error('Unexpected move message received for user "' + userId + '"'); return; } diff --git a/pusher/src/Server/server/formdata.ts b/pusher/src/Server/server/formdata.ts index 66e51db4..0c9992d8 100644 --- a/pusher/src/Server/server/formdata.ts +++ b/pusher/src/Server/server/formdata.ts @@ -2,6 +2,7 @@ import { createWriteStream } from "fs"; import { join, dirname } from "path"; import Busboy from "busboy"; import mkdirp from "mkdirp"; +import log from "../../Services/Logger"; function formData( contType: string, @@ -19,7 +20,7 @@ function formData( filename?: (oldName: string) => string; } = {} ) { - console.log("Enter form data"); + log.info("Enter form data"); options.headers = { "content-type": contType, }; diff --git a/pusher/src/Services/CpuTracker.ts b/pusher/src/Services/CpuTracker.ts index 3d06ca70..4ff48eb6 100644 --- a/pusher/src/Services/CpuTracker.ts +++ b/pusher/src/Services/CpuTracker.ts @@ -1,4 +1,5 @@ import { CPU_OVERHEAT_THRESHOLD } from "../Enum/EnvironmentVariable"; +import log from "./Logger"; function secNSec2ms(secNSec: Array | number) { if (Array.isArray(secNSec)) { @@ -28,16 +29,16 @@ class CpuTracker { if (!this.overHeating && this.cpuPercent > CPU_OVERHEAT_THRESHOLD) { this.overHeating = true; - console.warn('CPU high threshold alert. Going in "overheat" mode'); + log.warn('CPU high threshold alert. Going in "overheat" mode'); } else if (this.overHeating && this.cpuPercent <= CPU_OVERHEAT_THRESHOLD) { this.overHeating = false; - console.log('CPU is back to normal. Canceling "overheat" mode'); + log.info('CPU is back to normal. Canceling "overheat" mode'); } - /*console.log('elapsed time ms: ', elapTimeMS) - console.log('elapsed user ms: ', elapUserMS) - console.log('elapsed system ms:', elapSystMS) - console.log('cpu percent: ', this.cpuPercent)*/ + /*log.info('elapsed time ms: ', elapTimeMS) + log.info('elapsed user ms: ', elapUserMS) + log.info('elapsed system ms:', elapSystMS) + log.info('cpu percent: ', this.cpuPercent)*/ }, 100); } diff --git a/pusher/src/Services/IoSocketHelpers.ts b/pusher/src/Services/IoSocketHelpers.ts index 2da7c430..efe72e20 100644 --- a/pusher/src/Services/IoSocketHelpers.ts +++ b/pusher/src/Services/IoSocketHelpers.ts @@ -1,6 +1,7 @@ import { ExSocketInterface } from "_Model/Websocket/ExSocketInterface"; import { BatchMessage, ErrorMessage, ServerToClientMessage, SubMessage } from "../Messages/generated/messages_pb"; import { WebSocket } from "uWebSockets.js"; +import log from "./Logger"; export function emitInBatch(socket: ExSocketInterface, payload: SubMessage): void { socket.batchedMessages.addPayload(payload); @@ -31,5 +32,5 @@ export function emitError(Client: WebSocket, message: string): void { if (!Client.disconnecting) { Client.send(serverToClientMessage.serializeBinary().buffer, true); } - console.warn(message); + log.warn(message); } diff --git a/pusher/src/Services/Logger.ts b/pusher/src/Services/Logger.ts new file mode 100644 index 00000000..e19f60d1 --- /dev/null +++ b/pusher/src/Services/Logger.ts @@ -0,0 +1,16 @@ +import * as winston from "winston"; + +const logger = winston.createLogger({ + transports: [ + new winston.transports.Console({ + format: winston.format.combine( + winston.format.colorize(), + winston.format.timestamp(), + winston.format.align(), + winston.format.printf((info) => `${info.timestamp} ${info.level}: ${info.message}`) + ), + }), + ], +}); + +export default logger; diff --git a/pusher/src/Services/SocketManager.ts b/pusher/src/Services/SocketManager.ts index 40d58b64..d3458b3a 100644 --- a/pusher/src/Services/SocketManager.ts +++ b/pusher/src/Services/SocketManager.ts @@ -49,6 +49,7 @@ import { ExAdminSocketInterface } from "_Model/Websocket/ExAdminSocketInterface" import { WebSocket } from "uWebSockets.js"; import { isRoomRedirect } from "./AdminApi/RoomRedirect"; import { CharacterTexture } from "./AdminApi/CharacterTexture"; +import log from "./Logger"; const debug = Debug("socket"); @@ -115,15 +116,15 @@ export class SocketManager implements ZoneEventListener { } }) .on("end", () => { - console.warn("Admin connection lost to back server"); + log.warn("Admin connection lost to back server"); // Let's close the front connection if the back connection is closed. This way, we can retry connecting from the start. if (!client.disconnecting) { this.closeWebsocketConnection(client, 1011, "Admin Connection lost to back server"); } - console.log("A user left"); + log.info("A user left"); }) .on("error", (err: Error) => { - console.error("Error in connection to back server:", err); + log.error("Error in connection to back server:", err); if (!client.disconnecting) { this.closeWebsocketConnection(client, 1011, "Error while connecting to back server"); } @@ -166,7 +167,7 @@ export class SocketManager implements ZoneEventListener { joinRoomMessage.addCharacterlayer(characterLayerMessage); } - console.log("Calling joinRoom '"+client.roomId+"' for client "+client.userUuid); + log.info("Calling joinRoom '" + client.roomId + "' for client " + client.userUuid); const apiClient = await apiClientRepository.getClient(client.roomId); const streamToPusher = apiClient.joinRoom(); clientEventsEmitter.emitClientJoin(client.userUuid, client.roomId); @@ -198,12 +199,21 @@ export class SocketManager implements ZoneEventListener { if (!client.disconnecting) { this.closeWebsocketConnection(client, 1011, "Connection lost to back server"); } - console.log("Closed connection for user '"+client.userUuid+"' to back server "+apiClient.getChannel().getTarget()); + log.info( + "Closed connection for user '" + + client.userUuid + + "' to back server " + + apiClient.getChannel().getTarget() + ); }) .on("error", (err: Error) => { - console.error("Error in connection to back server '"+apiClient.getChannel().getTarget()+"':", err); + log.error("Error in connection to back server '" + apiClient.getChannel().getTarget() + "':", err); if (!client.disconnecting) { - this.closeWebsocketConnection(client, 1011, "Error while connecting to back server '"+apiClient.getChannel().getTarget()+"'"); + this.closeWebsocketConnection( + client, + 1011, + "Error while connecting to back server '" + apiClient.getChannel().getTarget() + "'" + ); } }); @@ -214,8 +224,8 @@ export class SocketManager implements ZoneEventListener { const pusherRoom = await this.getOrCreateRoom(client.roomId); pusherRoom.join(client); } catch (e) { - console.error('An error occurred on "join_room" event'); - console.error(e); + log.error('An error occurred on "join_room" event'); + log.error(e); } } @@ -232,13 +242,13 @@ export class SocketManager implements ZoneEventListener { const room = this.rooms.get(client.roomId); if (!room) { - console.error("In SET_VIEWPORT, could not find world with id '", client.roomId, "'"); + log.error("In SET_VIEWPORT, could not find world with id '", client.roomId, "'"); return; } room.setViewport(client, client.viewport); } catch (e) { - console.error('An error occurred on "SET_VIEWPORT" event'); - console.error(e); + log.error('An error occurred on "SET_VIEWPORT" event'); + log.error(e); } } @@ -309,8 +319,8 @@ export class SocketManager implements ZoneEventListener { client.roomId ); } catch (e) { - console.error('An error occurred on "handleReportMessage"'); - console.error(e); + log.error('An error occurred on "handleReportMessage"'); + log.error(e); } } @@ -345,14 +355,14 @@ export class SocketManager implements ZoneEventListener { debug("Room %s is empty. Deleting.", socket.roomId); } } else { - console.error("Could not find the GameRoom the user is leaving!"); + log.error("Could not find the GameRoom the user is leaving!"); } //user leave previous room //Client.leave(Client.roomId); } finally { //delete Client.roomId; clientEventsEmitter.emitClientLeave(socket.userUuid, socket.roomId); - console.log("User '"+socket.userUuid+"' left"); + log.info("User '" + socket.userUuid + "' left"); } } } finally { @@ -434,7 +444,7 @@ export class SocketManager implements ZoneEventListener { client.send(serverToClientMessage.serializeBinary().buffer, true); } catch (e) { - console.error("An error occurred while generating the Jitsi JWT token: ", e); + log.error("An error occurred while generating the Jitsi JWT token: ", e); } } @@ -458,7 +468,7 @@ export class SocketManager implements ZoneEventListener { backAdminMessage.setType(type); backConnection.sendAdminMessage(backAdminMessage, (error) => { if (error !== null) { - console.error("Error while sending admin message", error); + log.error("Error while sending admin message", error); } }); } @@ -483,7 +493,7 @@ export class SocketManager implements ZoneEventListener { banMessage.setType(type); backConnection.ban(banMessage, (error) => { if (error !== null) { - console.error("Error while sending admin message", error); + log.error("Error while sending admin message", error); } }); } diff --git a/pusher/yarn.lock b/pusher/yarn.lock index 820575aa..4461a86d 100644 --- a/pusher/yarn.lock +++ b/pusher/yarn.lock @@ -23,6 +23,15 @@ chalk "^2.0.0" js-tokens "^4.0.0" +"@dabh/diagnostics@^2.0.2": + version "2.0.2" + resolved "https://registry.yarnpkg.com/@dabh/diagnostics/-/diagnostics-2.0.2.tgz#290d08f7b381b8f94607dc8f471a12c675f9db31" + integrity sha512-+A1YivoVDNNVCdfozHSR8v/jyuuLTMXwjWuxPFlFlUapXoGc+Gj9mDlTDDfrwl7rXCl2tNZ0kE8sIBO6YOn96Q== + dependencies: + colorspace "1.1.x" + enabled "2.0.x" + kuler "^2.0.0" + "@mapbox/node-pre-gyp@^1.0.4": version "1.0.5" resolved "https://registry.yarnpkg.com/@mapbox/node-pre-gyp/-/node-pre-gyp-1.0.5.tgz#2a0b32fcb416fb3f2250fd24cb2a81421a4f5950" @@ -367,6 +376,11 @@ astral-regex@^2.0.0: resolved "https://registry.yarnpkg.com/astral-regex/-/astral-regex-2.0.0.tgz#483143c567aeed4785759c0865786dc77d7d2e31" integrity sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ== +async@^3.1.0: + version "3.2.2" + resolved "https://registry.yarnpkg.com/async/-/async-3.2.2.tgz#2eb7671034bb2194d45d30e31e24ec7e7f9670cd" + integrity sha512-H0E+qZaDEfx/FY4t7iLRv1W2fFI6+pyCeTw1uN20AQPiwqwM6ojPxHxdLv4z8hi2DtnW9BOckSspLucW7pIE5g== + axios@^0.21.2: version "0.21.2" resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.2.tgz#21297d5084b2aeeb422f5d38e7be4fbb82239017" @@ -549,7 +563,7 @@ code-point-at@^1.0.0: resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77" integrity sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c= -color-convert@^1.9.0: +color-convert@^1.9.0, color-convert@^1.9.3: version "1.9.3" resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" integrity sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg== @@ -568,16 +582,45 @@ color-name@1.1.3: resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" integrity sha1-p9BVi9icQveV3UIyj3QIMcpTvCU= -color-name@~1.1.4: +color-name@^1.0.0, color-name@~1.1.4: version "1.1.4" resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== +color-string@^1.6.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/color-string/-/color-string-1.6.0.tgz#c3915f61fe267672cb7e1e064c9d692219f6c312" + integrity sha512-c/hGS+kRWJutUBEngKKmk4iH3sD59MBkoxVapS/0wgpCz2u7XsNloxknyvBhzwEs1IbV36D9PwqLPJ2DTu3vMA== + dependencies: + color-name "^1.0.0" + simple-swizzle "^0.2.2" + +color@^3.1.3: + version "3.2.1" + resolved "https://registry.yarnpkg.com/color/-/color-3.2.1.tgz#3544dc198caf4490c3ecc9a790b54fe9ff45e164" + integrity sha512-aBl7dZI9ENN6fUGC7mWpMTPNHmWUSNan9tuWN6ahh5ZLNk9baLJOnSMlrQkHcrfFgz2/RigjUVAjdx36VcemKA== + dependencies: + color-convert "^1.9.3" + color-string "^1.6.0" + colorette@^1.2.2: version "1.2.2" resolved "https://registry.yarnpkg.com/colorette/-/colorette-1.2.2.tgz#cbcc79d5e99caea2dbf10eb3a26fd8b3e6acfa94" integrity sha512-MKGMzyfeuutC/ZJ1cba9NqcNpfeqMUcYmyF1ZFY6/Cn7CNSAKx6a+s48sqLqyAiZuaP2TcqMhoo+dlwFnVxT9w== +colors@^1.2.1: + version "1.4.0" + resolved "https://registry.yarnpkg.com/colors/-/colors-1.4.0.tgz#c50491479d4c1bdaed2c9ced32cf7c7dc2360f78" + integrity sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA== + +colorspace@1.1.x: + version "1.1.4" + resolved "https://registry.yarnpkg.com/colorspace/-/colorspace-1.1.4.tgz#8d442d1186152f60453bf8070cd66eb364e59243" + integrity sha512-BgvKJiuVu1igBUF2kEjRCZXol6wiiGbY5ipL/oVPwm0BL9sIpMIzM8IK7vwuxIIzOXMV3Ey5w+vxhm0rR/TN8w== + dependencies: + color "^3.1.3" + text-hex "1.0.x" + colour@~0.7.1: version "0.7.1" resolved "https://registry.yarnpkg.com/colour/-/colour-0.7.1.tgz#9cb169917ec5d12c0736d3e8685746df1cadf778" @@ -731,6 +774,11 @@ emoji-regex@^8.0.0: resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== +enabled@2.0.x: + version "2.0.0" + resolved "https://registry.yarnpkg.com/enabled/-/enabled-2.0.0.tgz#f9dd92ec2d6f4bbc0d5d1e64e21d61cd4665e7c2" + integrity sha512-AKrN98kuwOzMIdAizXGI86UFBoo26CL21UM763y1h/GMSJ4/OHU9k2YlsmBpyScFo/wbLzWQJBMCW4+IO3/+OQ== + end-of-stream@^1.1.0: version "1.4.4" resolved "https://registry.yarnpkg.com/end-of-stream/-/end-of-stream-1.4.4.tgz#5ae64a5f45057baf3626ec14da0ca5e4b2431eb0" @@ -909,6 +957,11 @@ fast-levenshtein@~2.0.6: resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917" integrity sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc= +fecha@^4.2.0: + version "4.2.1" + resolved "https://registry.yarnpkg.com/fecha/-/fecha-4.2.1.tgz#0a83ad8f86ef62a091e22bb5a039cd03d23eecce" + integrity sha512-MMMQ0ludy/nBs1/o0zVOiKTpG7qMbonKUzjJgQFEuvq6INZ1OraKPRAWkBq5vlKLOUMpmNYG1JoN3oDPUQ9m3Q== + figures@^3.0.0: version "3.2.0" resolved "https://registry.yarnpkg.com/figures/-/figures-3.2.0.tgz#625c18bd293c604dc4a8ddb2febf0c88341746af" @@ -949,6 +1002,11 @@ flatted@^2.0.0: resolved "https://registry.yarnpkg.com/flatted/-/flatted-2.0.2.tgz#4575b21e2bcee7434aa9be662f4b7b5f9c2b5138" integrity sha512-r5wGx7YeOwNWNlCA0wQ86zKyDLMQr+/RB8xy74M4hTphfmjlijTSSXGuH8rnvKZnfT9i+75zmd8jcKdMR4O6jA== +fn.name@1.x.x: + version "1.1.0" + resolved "https://registry.yarnpkg.com/fn.name/-/fn.name-1.1.0.tgz#26cad8017967aea8731bc42961d04a3d5988accc" + integrity sha512-GRnmB5gPyJpAhTQdSZTSp9uaPSvl09KoYcMQtsB9rQoOmzs9dH6ffeccH+Z+cv6P68Hu5bC6JjRh4Ah/mHSNRw== + follow-redirects@^1.14.0: version "1.14.4" resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.4.tgz#838fdf48a8bbdd79e52ee51fb1c94e3ed98b9379" @@ -1168,7 +1226,7 @@ inflight@^1.0.4: once "^1.3.0" wrappy "1" -inherits@2, inherits@~2.0.3: +inherits@2, inherits@^2.0.3, inherits@~2.0.3: version "2.0.4" resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== @@ -1202,6 +1260,11 @@ is-arrayish@^0.2.1: resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d" integrity sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0= +is-arrayish@^0.3.1: + version "0.3.2" + resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.3.2.tgz#4574a2ae56f7ab206896fb431eaeed066fdf8f03" + integrity sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ== + is-binary-path@~2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-2.1.0.tgz#ea1f7f3b80f064236e83470f86c09c254fb45b09" @@ -1373,6 +1436,11 @@ keyv@^4.0.0: dependencies: json-buffer "3.0.1" +kuler@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/kuler/-/kuler-2.0.0.tgz#e2c570a3800388fb44407e851531c1d670b061b3" + integrity sha512-Xq9nH7KlWZmXAtodXDDRE7vs6DU1gTU8zYDHDiWLSip45Egwq3plLHzPn27NgvzL2r1LMPC1vdqh98sQxtqj4A== + lcid@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/lcid/-/lcid-1.0.0.tgz#308accafa0bc483a3867b4b6f2b9506251d1b835" @@ -1495,6 +1563,17 @@ log-update@^4.0.0: slice-ansi "^4.0.0" wrap-ansi "^6.2.0" +logform@^2.2.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/logform/-/logform-2.3.0.tgz#a3997a05985de2ebd325ae0d166dffc9c6fe6b57" + integrity sha512-graeoWUH2knKbGthMtuG1EfaSPMZFZBIrhuJHhkS5ZseFBrc7DupCzihOQAzsK/qIKPQaPJ/lFQFctILUY5ARQ== + dependencies: + colors "^1.2.1" + fecha "^4.2.0" + ms "^2.1.1" + safe-stable-stringify "^1.1.0" + triple-beam "^1.3.0" + long@~3: version "3.2.0" resolved "https://registry.yarnpkg.com/long/-/long-3.2.0.tgz#d821b7138ca1cb581c172990ef14db200b5c474b" @@ -1687,6 +1766,13 @@ once@^1.3.0, once@^1.3.1, once@^1.4.0: dependencies: wrappy "1" +one-time@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/one-time/-/one-time-1.0.0.tgz#e06bc174aed214ed58edede573b433bbf827cb45" + integrity sha512-5DXOiRKwuSEcQ/l0kGCF6Q3jcADFv5tSmRaJck/OqkVFcOzutB134KRSfF0xDrL39MNnqxbHBbUUcjZIhTgb2g== + dependencies: + fn.name "1.x.x" + onetime@^5.1.0, onetime@^5.1.2: version "5.1.2" resolved "https://registry.yarnpkg.com/onetime/-/onetime-5.1.2.tgz#d0e96ebb56b07476df1dd9c4806e5237985ca45e" @@ -1867,7 +1953,7 @@ quick-lru@^5.1.1: resolved "https://registry.yarnpkg.com/quick-lru/-/quick-lru-5.1.1.tgz#366493e6b3e42a3a6885e2e99d18f80fb7a8c932" integrity sha512-WuyALRjWPDGtt/wzJiadO5AXY+8hZ80hVpe6MyivgraREW751X3SbhRvG3eLKOYN+8VEvqLcf3wdnt44Z4S4SA== -readable-stream@^2.0.6: +readable-stream@^2.0.6, readable-stream@^2.3.7: version "2.3.7" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.7.tgz#1eca1cf711aef814c04f62252a36a62f6cb23b57" integrity sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw== @@ -1880,6 +1966,15 @@ readable-stream@^2.0.6: string_decoder "~1.1.1" util-deprecate "~1.0.1" +readable-stream@^3.4.0: + version "3.6.0" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.6.0.tgz#337bbda3adc0706bd3e024426a286d4b4b2c9198" + integrity sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA== + dependencies: + inherits "^2.0.3" + string_decoder "^1.1.1" + util-deprecate "^1.0.1" + readdirp@~3.6.0: version "3.6.0" resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.6.0.tgz#74a370bd857116e245b29cc97340cd431a02a6c7" @@ -1963,7 +2058,7 @@ rxjs@^6.6.0, rxjs@^6.6.7: dependencies: tslib "^1.9.0" -safe-buffer@^5.0.1: +safe-buffer@^5.0.1, safe-buffer@~5.2.0: version "5.2.1" resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== @@ -1973,6 +2068,11 @@ safe-buffer@~5.1.0, safe-buffer@~5.1.1: resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== +safe-stable-stringify@^1.1.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/safe-stable-stringify/-/safe-stable-stringify-1.1.1.tgz#c8a220ab525cd94e60ebf47ddc404d610dc5d84a" + integrity sha512-ERq4hUjKDbJfE4+XtZLFPCDi8Vb1JqaxAPTxWFLBx8XcAlf9Bda/ZJdVezs/NAfsMQScyIlUMx+Yeu7P7rx5jw== + "safer-buffer@>= 2.1.2 < 3": version "2.1.2" resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" @@ -2034,6 +2134,13 @@ signal-exit@^3.0.0, signal-exit@^3.0.2, signal-exit@^3.0.3: resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.3.tgz#a1410c2edd8f077b08b4e253c8eacfcaf057461c" integrity sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA== +simple-swizzle@^0.2.2: + version "0.2.2" + resolved "https://registry.yarnpkg.com/simple-swizzle/-/simple-swizzle-0.2.2.tgz#a4da6b635ffcccca33f70d17cb92592de95e557a" + integrity sha1-pNprY1/8zMoz9w0Xy5JZLeleVXo= + dependencies: + is-arrayish "^0.3.1" + slice-ansi@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-2.1.0.tgz#cacd7693461a637a5788d92a7dd4fba068e81636" @@ -2084,6 +2191,11 @@ sprintf-js@~1.0.2: resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw= +stack-trace@0.0.x: + version "0.0.10" + resolved "https://registry.yarnpkg.com/stack-trace/-/stack-trace-0.0.10.tgz#547c70b347e8d32b4e108ea1a2a159e5fdde19c0" + integrity sha1-VHxws0fo0ytOEI6hoqFZ5f3eGcA= + streamsearch@0.1.2: version "0.1.2" resolved "https://registry.yarnpkg.com/streamsearch/-/streamsearch-0.1.2.tgz#808b9d0e56fc273d809ba57338e929919a1a9f1a" @@ -2134,6 +2246,13 @@ string-width@^4.1.0, string-width@^4.2.0: is-fullwidth-code-point "^3.0.0" strip-ansi "^6.0.0" +string_decoder@^1.1.1: + version "1.3.0" + resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.3.0.tgz#42f114594a46cf1a8e30b0a84f56c78c3edac21e" + integrity sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA== + dependencies: + safe-buffer "~5.2.0" + string_decoder@~1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.1.1.tgz#9cf1611ba62685d7030ae9e4ba34149c3af03fc8" @@ -2241,6 +2360,11 @@ tdigest@^0.1.1: dependencies: bintrees "1.0.1" +text-hex@1.0.x: + version "1.0.0" + resolved "https://registry.yarnpkg.com/text-hex/-/text-hex-1.0.0.tgz#69dc9c1b17446ee79a92bf5b884bb4b9127506f5" + integrity sha512-uuVGNWzgJ4yhRaNSiubPY7OjISw4sw4E5Uv0wbjp+OzcbmVU/rsT8ujgcXJhn9ypzsgr5vlzpPqP+MBBKcGvbg== + text-table@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" @@ -2270,6 +2394,11 @@ tree-kill@^1.2.2: resolved "https://registry.yarnpkg.com/tree-kill/-/tree-kill-1.2.2.tgz#4ca09a9092c88b73a7cdc5e8a01b507b0790a0cc" integrity sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A== +triple-beam@^1.2.0, triple-beam@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/triple-beam/-/triple-beam-1.3.0.tgz#a595214c7298db8339eeeee083e4d10bd8cb8dd9" + integrity sha512-XrHUvV5HpdLmIj4uVMxHggLbFSZYIn7HEWsqePZcI50pco+MPqJ50wMGY794X7AOOhxOBAjbkqfAbEe/QMp2Lw== + ts-node-dev@^1.0.0-pre.44: version "1.1.8" resolved "https://registry.yarnpkg.com/ts-node-dev/-/ts-node-dev-1.1.8.tgz#95520d8ab9d45fffa854d6668e2f8f9286241066" @@ -2353,7 +2482,7 @@ uri-js@^4.2.2: dependencies: punycode "^2.1.0" -util-deprecate@~1.0.1: +util-deprecate@^1.0.1, util-deprecate@~1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" integrity sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8= @@ -2402,6 +2531,29 @@ window-size@^0.1.4: resolved "https://registry.yarnpkg.com/window-size/-/window-size-0.1.4.tgz#f8e1aa1ee5a53ec5bf151ffa09742a6ad7697876" integrity sha1-+OGqHuWlPsW/FR/6CXQqatdpeHY= +winston-transport@^4.4.0: + version "4.4.0" + resolved "https://registry.yarnpkg.com/winston-transport/-/winston-transport-4.4.0.tgz#17af518daa690d5b2ecccaa7acf7b20ca7925e59" + integrity sha512-Lc7/p3GtqtqPBYYtS6KCN3c77/2QCev51DvcJKbkFPQNoj1sinkGwLGFDxkXY9J6p9+EPnYs+D90uwbnaiURTw== + dependencies: + readable-stream "^2.3.7" + triple-beam "^1.2.0" + +winston@^3.3.3: + version "3.3.3" + resolved "https://registry.yarnpkg.com/winston/-/winston-3.3.3.tgz#ae6172042cafb29786afa3d09c8ff833ab7c9170" + integrity sha512-oEXTISQnC8VlSAKf1KYSSd7J6IWuRPQqDdo8eoRNaYKLvwSb5+79Z3Yi1lrl6KDpU6/VWaxpakDAtb1oQ4n9aw== + dependencies: + "@dabh/diagnostics" "^2.0.2" + async "^3.1.0" + is-stream "^2.0.0" + logform "^2.2.0" + one-time "^1.0.0" + readable-stream "^3.4.0" + stack-trace "0.0.x" + triple-beam "^1.3.0" + winston-transport "^4.4.0" + word-wrap@~1.2.3: version "1.2.3" resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.3.tgz#610636f6b1f703891bd34771ccb17fb93b47079c" From 6a7385947d9fa132c3cb16d8dc7f5f3780ea39de Mon Sep 17 00:00:00 2001 From: Alexis Faizeau Date: Wed, 24 Nov 2021 11:55:28 +0100 Subject: [PATCH 05/18] Fix authentication mandatory --- front/src/Connexion/Room.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/front/src/Connexion/Room.ts b/front/src/Connexion/Room.ts index 2f408126..f206d318 100644 --- a/front/src/Connexion/Room.ts +++ b/front/src/Connexion/Room.ts @@ -107,7 +107,8 @@ export class Room { this._mapUrl = data.mapUrl; this._textures = data.textures; this._group = data.group; - this._authenticationMandatory = data.authenticationMandatory || DISABLE_ANONYMOUS; + this._authenticationMandatory = + data.authenticationMandatory != null ? data.authenticationMandatory : DISABLE_ANONYMOUS; this._iframeAuthentication = data.iframeAuthentication || OPID_LOGIN_SCREEN_PROVIDER; this._contactPage = data.contactPage || CONTACT_URL; return new MapDetail(data.mapUrl, data.textures); From 24640d13bba71a3f475de9483a8ba932783fc7d2 Mon Sep 17 00:00:00 2001 From: Alexis Faizeau Date: Wed, 24 Nov 2021 14:50:19 +0100 Subject: [PATCH 06/18] Fix removing of co-website action trigger --- .../Phaser/Game/GameMapPropertiesListener.ts | 80 +++++++++---------- 1 file changed, 38 insertions(+), 42 deletions(-) diff --git a/front/src/Phaser/Game/GameMapPropertiesListener.ts b/front/src/Phaser/Game/GameMapPropertiesListener.ts index 5a033d5c..dad55768 100644 --- a/front/src/Phaser/Game/GameMapPropertiesListener.ts +++ b/front/src/Phaser/Game/GameMapPropertiesListener.ts @@ -4,10 +4,8 @@ import { scriptUtils } from "../../Api/ScriptUtils"; import type { CoWebsite } from "../../WebRtc/CoWebsiteManager"; import { coWebsiteManager } from "../../WebRtc/CoWebsiteManager"; import { layoutManagerActionStore } from "../../Stores/LayoutManagerStore"; -import { get } from 'svelte/store'; -import { - ON_ACTION_TRIGGER_BUTTON, -} from "../../WebRtc/LayoutManager"; +import { get } from "svelte/store"; +import { ON_ACTION_TRIGGER_BUTTON } from "../../WebRtc/LayoutManager"; import type { ITiledMapLayer } from "../Map/ITiledMap"; import { GameMapProperties } from "./GameMapProperties"; @@ -18,8 +16,8 @@ enum OpenCoWebsiteState { } interface OpenCoWebsite { - coWebsite: CoWebsite | undefined, - state: OpenCoWebsiteState + coWebsite: CoWebsite | undefined; + state: OpenCoWebsiteState; } export class GameMapPropertiesListener { @@ -29,7 +27,7 @@ export class GameMapPropertiesListener { constructor(private scene: GameScene, private gameMap: GameMap) {} register() { - this.gameMap.onPropertyChange(GameMapProperties.OPEN_TAB, (newValue, oldvalue, allProps) => { + this.gameMap.onPropertyChange(GameMapProperties.OPEN_TAB, (newValue, oldValue, allProps) => { if (newValue === undefined) { layoutManagerActionStore.removeAction("openTab"); } @@ -53,10 +51,10 @@ export class GameMapPropertiesListener { } }); - // Open a new co-website by the property. + // Open a new co-website by the property. this.gameMap.onEnterLayer((newLayers) => { const handler = () => { - newLayers.forEach(layer => { + newLayers.forEach((layer) => { if (!layer.properties) { return; } @@ -69,8 +67,8 @@ export class GameMapPropertiesListener { let websiteTriggerProperty: string | undefined; let websiteTriggerMessageProperty: string | undefined; - layer.properties.forEach(property => { - switch(property.name) { + layer.properties.forEach((property) => { + switch (property.name) { case GameMapProperties.OPEN_WEBSITE: openWebsiteProperty = property.value as string | undefined; break; @@ -111,26 +109,28 @@ export class GameMapPropertiesListener { }); const openWebsiteFunction = () => { - coWebsiteManager.loadCoWebsite( - openWebsiteProperty as string, - this.scene.MapUrlFile, - allowApiProperty, - websitePolicyProperty, - websiteWidthProperty, - websitePositionProperty, - ).then(coWebsite => { - const coWebsiteOpen = this.coWebsitesOpenByLayer.get(layer); - if (coWebsiteOpen && coWebsiteOpen.state === OpenCoWebsiteState.MUST_BE_CLOSE) { - coWebsiteManager.closeCoWebsite(coWebsite); - this.coWebsitesOpenByLayer.delete(layer); - this.coWebsitesActionTriggerByLayer.delete(layer); - } else { - this.coWebsitesOpenByLayer.set(layer, { - coWebsite, - state: OpenCoWebsiteState.OPENED - }); - } - }); + coWebsiteManager + .loadCoWebsite( + openWebsiteProperty as string, + this.scene.MapUrlFile, + allowApiProperty, + websitePolicyProperty, + websiteWidthProperty, + websitePositionProperty + ) + .then((coWebsite) => { + const coWebsiteOpen = this.coWebsitesOpenByLayer.get(layer); + if (coWebsiteOpen && coWebsiteOpen.state === OpenCoWebsiteState.MUST_BE_CLOSE) { + coWebsiteManager.closeCoWebsite(coWebsite); + this.coWebsitesOpenByLayer.delete(layer); + this.coWebsitesActionTriggerByLayer.delete(layer); + } else { + this.coWebsitesOpenByLayer.set(layer, { + coWebsite, + state: OpenCoWebsiteState.OPENED, + }); + } + }); layoutManagerActionStore.removeAction(actionUuid); }; @@ -161,7 +161,7 @@ export class GameMapPropertiesListener { // Close opened co-websites on leave the layer who contain the property. this.gameMap.onLeaveLayer((oldLayers) => { const handler = () => { - oldLayers.forEach(layer => { + oldLayers.forEach((layer) => { if (!layer.properties) { return; } @@ -169,8 +169,8 @@ export class GameMapPropertiesListener { let openWebsiteProperty: string | undefined; let websiteTriggerProperty: string | undefined; - layer.properties.forEach(property => { - switch(property.name) { + layer.properties.forEach((property) => { + switch (property.name) { case GameMapProperties.OPEN_WEBSITE: openWebsiteProperty = property.value as string | undefined; break; @@ -192,11 +192,6 @@ export class GameMapPropertiesListener { if (coWebsiteOpen.state === OpenCoWebsiteState.LOADING) { coWebsiteOpen.state = OpenCoWebsiteState.MUST_BE_CLOSE; - return; - } - - if (coWebsiteOpen.state !== OpenCoWebsiteState.OPENED) { - return; } if (coWebsiteOpen.coWebsite !== undefined) { @@ -216,9 +211,10 @@ export class GameMapPropertiesListener { return; } - const action = actionStore && actionStore.length > 0 ? - actionStore.find(action => action.uuid === actionTriggerUuid) : undefined; - + const action = + actionStore && actionStore.length > 0 + ? actionStore.find((action) => action.uuid === actionTriggerUuid) + : undefined; if (action) { layoutManagerActionStore.removeAction(actionTriggerUuid); From 7c6105d93a3b81ced8e8b858c8d762e72284ed9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Wed, 24 Nov 2021 15:21:07 +0100 Subject: [PATCH 07/18] Making the loader resizable This way, if the window is resized while loading, the loading bar will stay in the middle --- front/src/Phaser/Components/Loader.ts | 161 +++++++++++------- front/src/Phaser/Game/GameScene.ts | 10 +- front/src/Phaser/Login/CustomizeScene.ts | 7 +- .../src/Phaser/Login/SelectCharacterScene.ts | 6 +- .../src/Phaser/Login/SelectCompanionScene.ts | 6 +- 5 files changed, 121 insertions(+), 69 deletions(-) diff --git a/front/src/Phaser/Components/Loader.ts b/front/src/Phaser/Components/Loader.ts index d126aded..0534aa91 100644 --- a/front/src/Phaser/Components/Loader.ts +++ b/front/src/Phaser/Components/Loader.ts @@ -6,73 +6,114 @@ const TextName: string = "Loading..."; const LogoResource: string = "static/images/logo.png"; const LogoFrame: ImageFrameConfig = { frameWidth: 310, frameHeight: 60 }; -export const addLoader = (scene: Phaser.Scene): void => { - // If there is nothing to load, do not display the loader. - if (scene.load.list.entries.length === 0) { - return; +const loadingBarHeight: number = 16; +const padding: number = 5; + +export class Loader { + private progressContainer!: Phaser.GameObjects.Graphics; + private progress!: Phaser.GameObjects.Graphics; + private progressAmount: number = 0; + private logo: Phaser.GameObjects.Image|undefined; + private loadingText: Phaser.GameObjects.Text | null = null; + + public constructor(private scene: Phaser.Scene) { } - let loadingText: Phaser.GameObjects.Text | null = null; - const loadingBarWidth: number = Math.floor(scene.game.renderer.width / 3); - const loadingBarHeight: number = 16; - const padding: number = 5; - const promiseLoadLogoTexture = new Promise((res) => { - if (scene.load.textureManager.exists(LogoNameIndex)) { - return res( - scene.add.image(scene.game.renderer.width / 2, scene.game.renderer.height / 2 - 150, LogoNameIndex) - ); - } else { - //add loading if logo image is not ready - loadingText = scene.add.text(scene.game.renderer.width / 2, scene.game.renderer.height / 2 - 50, TextName); + public addLoader(): void { + // If there is nothing to load, do not display the loader. + if (this.scene.load.list.entries.length === 0) { + return; } - scene.load.spritesheet(LogoNameIndex, LogoResource, LogoFrame); - scene.load.once(`filecomplete-spritesheet-${LogoNameIndex}`, () => { - if (loadingText) { - loadingText.destroy(); + + const loadingBarWidth: number = Math.floor(this.scene.game.renderer.width / 3); + + const promiseLoadLogoTexture = new Promise((res) => { + if (this.scene.load.textureManager.exists(LogoNameIndex)) { + return res( + this.logo = this.scene.add.image(this.scene.game.renderer.width / 2, this.scene.game.renderer.height / 2 - 150, LogoNameIndex) + ); + } else { + //add loading if logo image is not ready + this.loadingText = this.scene.add.text(this.scene.game.renderer.width / 2, this.scene.game.renderer.height / 2 - 50, TextName); } - return res( - scene.add.image(scene.game.renderer.width / 2, scene.game.renderer.height / 2 - 150, LogoNameIndex) - ); + this.scene.load.spritesheet(LogoNameIndex, LogoResource, LogoFrame); + this.scene.load.once(`filecomplete-spritesheet-${LogoNameIndex}`, () => { + if (this.loadingText) { + this.loadingText.destroy(); + } + return res( + this.logo = this.scene.add.image(this.scene.game.renderer.width / 2, this.scene.game.renderer.height / 2 - 150, LogoNameIndex) + ); + }); }); - }); - const progressContainer = scene.add.graphics(); - const progress = scene.add.graphics(); - progressContainer.fillStyle(0x444444, 0.8); - progressContainer.fillRect( - (scene.game.renderer.width - loadingBarWidth) / 2 - padding, - scene.game.renderer.height / 2 + 50 - padding, - loadingBarWidth + padding * 2, - loadingBarHeight + padding * 2 - ); + this.progressContainer = this.scene.add.graphics(); + this.progress = this.scene.add.graphics(); + this.progressContainer.fillStyle(0x444444, 0.8); - scene.load.on("progress", (value: number) => { - progress.clear(); - progress.fillStyle(0xbbbbbb, 1); - progress.fillRect( - (scene.game.renderer.width - loadingBarWidth) / 2, - scene.game.renderer.height / 2 + 50, - loadingBarWidth * value, + this.resize(); + + this.scene.load.on("progress", (value: number) => { + this.progressAmount = value; + this.drawProgress(); + }); + this.scene.load.on("complete", () => { + if (this.loadingText) { + this.loadingText.destroy(); + } + promiseLoadLogoTexture.then((resLoadingImage: Phaser.GameObjects.Image) => { + resLoadingImage.destroy(); + }); + this.progress.destroy(); + this.progressContainer.destroy(); + if (this.scene instanceof DirtyScene) { + this.scene.markDirty(); + } + }); + } + + + public removeLoader(): void { + if (this.scene.load.textureManager.exists(LogoNameIndex)) { + this.scene.load.textureManager.remove(LogoNameIndex); + } + } + + public resize(): void { + const loadingBarWidth: number = Math.floor(this.scene.game.renderer.width / 3); + + this.progressContainer.clear(); + this.progressContainer.fillStyle(0x444444, 0.8); + this.progressContainer.fillRect( + (this.scene.game.renderer.width - loadingBarWidth) / 2 - padding, + this.scene.game.renderer.height / 2 + 50 - padding, + loadingBarWidth + padding * 2, + loadingBarHeight + padding * 2 + ); + + this.drawProgress(); + + if (this.loadingText) { + this.loadingText.x = this.scene.game.renderer.width / 2; + this.loadingText.y = this.scene.game.renderer.height / 2 - 50; + } + + if (this.logo) { + this.logo.x = this.scene.game.renderer.width / 2; + this.logo.y = this.scene.game.renderer.height / 2 - 150; + } + } + + private drawProgress() { + const loadingBarWidth: number = Math.floor(this.scene.game.renderer.width / 3); + + this.progress.clear(); + this.progress.fillStyle(0xbbbbbb, 1); + this.progress.fillRect( + (this.scene.game.renderer.width - loadingBarWidth) / 2, + this.scene.game.renderer.height / 2 + 50, + loadingBarWidth * this.progressAmount, loadingBarHeight ); - }); - scene.load.on("complete", () => { - if (loadingText) { - loadingText.destroy(); - } - promiseLoadLogoTexture.then((resLoadingImage: Phaser.GameObjects.Image) => { - resLoadingImage.destroy(); - }); - progress.destroy(); - progressContainer.destroy(); - if (scene instanceof DirtyScene) { - scene.markDirty(); - } - }); -}; - -export const removeLoader = (scene: Phaser.Scene): void => { - if (scene.load.textureManager.exists(LogoNameIndex)) { - scene.load.textureManager.remove(LogoNameIndex); } -}; +} diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index 81cf3676..d9bb8186 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -28,7 +28,7 @@ import { localUserStore } from "../../Connexion/LocalUserStore"; import { HtmlUtils } from "../../WebRtc/HtmlUtils"; import { mediaManager } from "../../WebRtc/MediaManager"; import { SimplePeer } from "../../WebRtc/SimplePeer"; -import { addLoader, removeLoader } from "../Components/Loader"; +import { Loader } from "../Components/Loader"; import { lazyLoadPlayerCharacterTextures, loadCustomTexture } from "../Entity/PlayerTexturesLoadingManager"; import { RemotePlayer } from "../Entity/RemotePlayer"; import type { ActionableItem } from "../Items/ActionableItem"; @@ -203,6 +203,7 @@ export class GameScene extends DirtyScene { private sharedVariablesManager!: SharedVariablesManager; private objectsByType = new Map(); private embeddedWebsiteManager!: EmbeddedWebsiteManager; + private loader: Loader; constructor(private room: Room, MapUrlFile: string, customKey?: string | undefined) { super({ @@ -221,6 +222,7 @@ export class GameScene extends DirtyScene { this.connectionAnswerPromise = new Promise((resolve, reject): void => { this.connectionAnswerPromiseResolve = resolve; }); + this.loader = new Loader(this); } //hook preload scene @@ -297,7 +299,7 @@ export class GameScene extends DirtyScene { //if SpriteSheetFile (WOKA file) don't display error and give an access for user if (this.preloading && !(file instanceof SpriteSheetFile)) { //remove loader in progress - removeLoader(this); + this.loader.removeLoader(); //display an error scene this.scene.start(ErrorSceneName, { @@ -331,7 +333,7 @@ export class GameScene extends DirtyScene { }); //this function must stay at the end of preload function - addLoader(this); + this.loader.addLoader(); } // FIXME: we need to put a "unknown" instead of a "any" and validate the structure of the JSON we are receiving. @@ -1832,6 +1834,8 @@ ${escapedMessage} right: camera.scrollX + camera.width, bottom: camera.scrollY + camera.height, }); + + this.loader.resize(); } private getObjectLayerData(objectName: string): ITiledMapObject | undefined { for (const layer of this.mapFile.layers) { diff --git a/front/src/Phaser/Login/CustomizeScene.ts b/front/src/Phaser/Login/CustomizeScene.ts index 8cb82ba6..d5629c88 100644 --- a/front/src/Phaser/Login/CustomizeScene.ts +++ b/front/src/Phaser/Login/CustomizeScene.ts @@ -4,7 +4,7 @@ import { loadAllLayers } from "../Entity/PlayerTexturesLoadingManager"; import Sprite = Phaser.GameObjects.Sprite; import { gameManager } from "../Game/GameManager"; import { localUserStore } from "../../Connexion/LocalUserStore"; -import { addLoader } from "../Components/Loader"; +import { Loader } from "../Components/Loader"; import type { BodyResourceDescriptionInterface } from "../Entity/PlayerTextures"; import { AbstractCharacterScene } from "./AbstractCharacterScene"; import { areCharacterLayersValid } from "../../Connexion/LocalUser"; @@ -30,10 +30,13 @@ export class CustomizeScene extends AbstractCharacterScene { private moveHorizontally: number = 0; private moveVertically: number = 0; + private loader: Loader; + constructor() { super({ key: CustomizeSceneName, }); + this.loader = new Loader(this); } preload() { @@ -55,7 +58,7 @@ export class CustomizeScene extends AbstractCharacterScene { this.lazyloadingAttempt = false; //this function must stay at the end of preload function - addLoader(this); + this.loader.addLoader(); } create() { diff --git a/front/src/Phaser/Login/SelectCharacterScene.ts b/front/src/Phaser/Login/SelectCharacterScene.ts index 1f1eb3ce..d9861b20 100644 --- a/front/src/Phaser/Login/SelectCharacterScene.ts +++ b/front/src/Phaser/Login/SelectCharacterScene.ts @@ -4,7 +4,7 @@ import { EnableCameraSceneName } from "./EnableCameraScene"; import { CustomizeSceneName } from "./CustomizeScene"; import { localUserStore } from "../../Connexion/LocalUserStore"; import { loadAllDefaultModels } from "../Entity/PlayerTexturesLoadingManager"; -import { addLoader } from "../Components/Loader"; +import { Loader} from "../Components/Loader"; import type { BodyResourceDescriptionInterface } from "../Entity/PlayerTextures"; import { AbstractCharacterScene } from "./AbstractCharacterScene"; import { areCharacterLayersValid } from "../../Connexion/LocalUser"; @@ -31,11 +31,13 @@ export class SelectCharacterScene extends AbstractCharacterScene { protected pointerTimer: number = 0; protected lazyloadingAttempt = true; //permit to update texture loaded after renderer + private loader: Loader; constructor() { super({ key: SelectCharacterSceneName, }); + this.loader = new Loader(this); } preload() { @@ -49,7 +51,7 @@ export class SelectCharacterScene extends AbstractCharacterScene { this.lazyloadingAttempt = false; //this function must stay at the end of preload function - addLoader(this); + this.loader.addLoader(); } create() { diff --git a/front/src/Phaser/Login/SelectCompanionScene.ts b/front/src/Phaser/Login/SelectCompanionScene.ts index 46ad6361..615ac4b3 100644 --- a/front/src/Phaser/Login/SelectCompanionScene.ts +++ b/front/src/Phaser/Login/SelectCompanionScene.ts @@ -1,4 +1,4 @@ -import { addLoader } from "../Components/Loader"; +import { Loader } from "../Components/Loader"; import { gameManager } from "../Game/GameManager"; import { ResizableScene } from "./ResizableScene"; import { EnableCameraSceneName } from "./EnableCameraScene"; @@ -22,11 +22,13 @@ export class SelectCompanionScene extends ResizableScene { private currentCompanion = 0; private pointerClicked: boolean = false; private pointerTimer: number = 0; + private loader: Loader; constructor() { super({ key: SelectCompanionSceneName, }); + this.loader = new Loader(this); } preload() { @@ -35,7 +37,7 @@ export class SelectCompanionScene extends ResizableScene { }); //this function must stay at the end of preload function - addLoader(this); + this.loader.addLoader(); } create() { From d3bd99b5ee83e8fd64ce33d37b1e59df88337ad8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Wed, 24 Nov 2021 15:24:24 +0100 Subject: [PATCH 08/18] Fixing running of prettier check on the front --- .github/workflows/continuous_integration.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/continuous_integration.yml b/.github/workflows/continuous_integration.yml index a90d9397..fcde792a 100644 --- a/.github/workflows/continuous_integration.yml +++ b/.github/workflows/continuous_integration.yml @@ -62,18 +62,13 @@ jobs: working-directory: "front" - name: "Pretty" - run: yarn run pretty + run: yarn run pretty-check working-directory: "front" - name: "Jasmine" run: yarn test working-directory: "front" - # We will enable prettier checks on front in a few month, when most PRs without prettier have been merged - # - name: "Prettier" - # run: yarn run pretty-check - # working-directory: "front" - continuous-integration-pusher: name: "Continuous Integration Pusher" From 2cbf5b56afd5cbbfe4a44aa82aac54c4d1a9e875 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Wed, 24 Nov 2021 15:29:12 +0100 Subject: [PATCH 09/18] Fixing linting --- front/src/Administration/AnalyticsClient.ts | 74 +++++++--------- front/src/Api/Events/CloseCoWebsiteEvent.ts | 2 +- front/src/Api/Events/IframeEvent.ts | 12 ++- front/src/Api/Events/OpenCoWebsiteEvent.ts | 2 +- front/src/Api/IframeListener.ts | 2 +- front/src/Api/iframe/nav.ts | 2 +- front/src/Connexion/LocalUserStore.ts | 4 +- front/src/Phaser/Game/GameMap.ts | 8 +- front/src/Phaser/Game/GameMapProperties.ts | 70 +++++++-------- .../Phaser/Game/GameMapPropertiesListener.ts | 73 +++++++-------- front/src/Stores/LayoutManagerStore.ts | 2 - front/src/WebRtc/JitsiFactory.ts | 88 ++++++++++--------- 12 files changed, 164 insertions(+), 175 deletions(-) diff --git a/front/src/Administration/AnalyticsClient.ts b/front/src/Administration/AnalyticsClient.ts index ee85e8f4..fb2b604b 100644 --- a/front/src/Administration/AnalyticsClient.ts +++ b/front/src/Administration/AnalyticsClient.ts @@ -4,7 +4,7 @@ declare let window: any; class AnalyticsClient { // eslint-disable-next-line @typescript-eslint/no-explicit-any - private posthogPromise: Promise|undefined; + private posthogPromise: Promise | undefined; constructor() { if (POSTHOG_API_KEY && POSTHOG_URL) { @@ -18,74 +18,64 @@ class AnalyticsClient { } identifyUser(uuid: string, email: string | null) { - this.posthogPromise - ?.then((posthog) => { - posthog.identify(uuid, { uuid, email, wa: true }); - }); + this.posthogPromise?.then((posthog) => { + posthog.identify(uuid, { uuid, email, wa: true }); + }); } loggedWithSso() { - this.posthogPromise - ?.then((posthog) => { - posthog.capture("wa-logged-sso"); - }); + this.posthogPromise?.then((posthog) => { + posthog.capture("wa-logged-sso"); + }); } loggedWithToken() { - this.posthogPromise - ?.then((posthog) => { - posthog.capture("wa-logged-token"); - }); + this.posthogPromise?.then((posthog) => { + posthog.capture("wa-logged-token"); + }); } enteredRoom(roomId: string, roomGroup: string | null) { - this.posthogPromise - ?.then((posthog) => { - posthog.capture("$pageView", { roomId, roomGroup }); - posthog.capture("enteredRoom"); - }); + this.posthogPromise?.then((posthog) => { + posthog.capture("$pageView", { roomId, roomGroup }); + posthog.capture("enteredRoom"); + }); } openedMenu() { - this.posthogPromise - ?.then((posthog) => { - posthog.capture("wa-opened-menu"); - }); + this.posthogPromise?.then((posthog) => { + posthog.capture("wa-opened-menu"); + }); } launchEmote(emote: string) { - this.posthogPromise - ?.then((posthog) => { - posthog.capture("wa-emote-launch", { emote }); - }); + this.posthogPromise?.then((posthog) => { + posthog.capture("wa-emote-launch", { emote }); + }); } enteredJitsi(roomName: string, roomId: string) { - this.posthogPromise - ?.then((posthog) => { - posthog.capture("wa-entered-jitsi", { roomName, roomId }); - }); + this.posthogPromise?.then((posthog) => { + posthog.capture("wa-entered-jitsi", { roomName, roomId }); + }); } validationName() { - this.posthogPromise - ?.then((posthog) => { - posthog.capture("wa-name-validation"); - }); + this.posthogPromise?.then((posthog) => { + posthog.capture("wa-name-validation"); + }); } validationWoka(scene: string) { - this.posthogPromise - ?.then((posthog) => { - posthog.capture("wa-woka-validation", { scene }); - }); + this.posthogPromise?.then((posthog) => { + posthog.capture("wa-woka-validation", { scene }); + }); } validationVideo() { - this.posthogPromise - ?.then((posthog) => { - posthog.capture("wa-video-validation"); - }); + this.posthogPromise?.then((posthog) => { + posthog.capture("wa-video-validation"); + }); } } export const analyticsClient = new AnalyticsClient(); diff --git a/front/src/Api/Events/CloseCoWebsiteEvent.ts b/front/src/Api/Events/CloseCoWebsiteEvent.ts index 94167d5e..4dc1e51d 100644 --- a/front/src/Api/Events/CloseCoWebsiteEvent.ts +++ b/front/src/Api/Events/CloseCoWebsiteEvent.ts @@ -2,7 +2,7 @@ import * as tg from "generic-type-guard"; export const isCloseCoWebsite = new tg.IsInterface() .withProperties({ - id: tg.isOptional(tg.isString) + id: tg.isOptional(tg.isString), }) .get(); diff --git a/front/src/Api/Events/IframeEvent.ts b/front/src/Api/Events/IframeEvent.ts index abb492c5..081008c4 100644 --- a/front/src/Api/Events/IframeEvent.ts +++ b/front/src/Api/Events/IframeEvent.ts @@ -24,9 +24,7 @@ import type { EmbeddedWebsite } from "../iframe/Room/EmbeddedWebsite"; import { isCreateEmbeddedWebsiteEvent } from "./EmbeddedWebsiteEvent"; import type { LoadTilesetEvent } from "./LoadTilesetEvent"; import { isLoadTilesetEvent } from "./LoadTilesetEvent"; -import type { - MessageReferenceEvent, -} from "./ui/TriggerActionMessageEvent"; +import type { MessageReferenceEvent } from "./ui/TriggerActionMessageEvent"; import { isMessageReferenceEvent, isTriggerActionMessageEvent } from "./ui/TriggerActionMessageEvent"; import type { MenuRegisterEvent, UnregisterMenuEvent } from "./ui/MenuRegisterEvent"; import type { ChangeLayerEvent } from "./ChangeLayerEvent"; @@ -117,19 +115,19 @@ export const iframeQueryMapTypeGuards = { }, openCoWebsite: { query: isOpenCoWebsiteEvent, - answer: isCoWebsite + answer: isCoWebsite, }, getCoWebsites: { query: tg.isUndefined, - answer: tg.isArray(isCoWebsite) + answer: tg.isArray(isCoWebsite), }, closeCoWebsite: { query: tg.isString, - answer: tg.isUndefined + answer: tg.isUndefined, }, closeCoWebsites: { query: tg.isUndefined, - answer: tg.isUndefined + answer: tg.isUndefined, }, triggerActionMessage: { query: isTriggerActionMessageEvent, diff --git a/front/src/Api/Events/OpenCoWebsiteEvent.ts b/front/src/Api/Events/OpenCoWebsiteEvent.ts index 9c02b7a3..514fd110 100644 --- a/front/src/Api/Events/OpenCoWebsiteEvent.ts +++ b/front/src/Api/Events/OpenCoWebsiteEvent.ts @@ -5,7 +5,7 @@ export const isOpenCoWebsiteEvent = new tg.IsInterface() url: tg.isString, allowApi: tg.isOptional(tg.isBoolean), allowPolicy: tg.isOptional(tg.isString), - position: tg.isOptional(tg.isNumber) + position: tg.isOptional(tg.isNumber), }) .get(); diff --git a/front/src/Api/IframeListener.ts b/front/src/Api/IframeListener.ts index 871ec3b9..f30ce80c 100644 --- a/front/src/Api/IframeListener.ts +++ b/front/src/Api/IframeListener.ts @@ -49,7 +49,7 @@ class IframeListener { public readonly openTabStream = this._openTabStream.asObservable(); private readonly _loadPageStream: Subject = new Subject(); - public readonly loadPageStream = this._loadPageStream.asObservable() + public readonly loadPageStream = this._loadPageStream.asObservable(); private readonly _disablePlayerControlStream: Subject = new Subject(); public readonly disablePlayerControlStream = this._disablePlayerControlStream.asObservable(); diff --git a/front/src/Api/iframe/nav.ts b/front/src/Api/iframe/nav.ts index 5acfa2a5..206961bf 100644 --- a/front/src/Api/iframe/nav.ts +++ b/front/src/Api/iframe/nav.ts @@ -57,7 +57,7 @@ export class WorkadventureNavigationCommands extends IframeApiContribution { const result = await queryWorkadventure({ type: "getCoWebsites", - data: undefined + data: undefined, }); return result.map((cowebsiteEvent) => new CoWebsite(cowebsiteEvent.id, cowebsiteEvent.position)); } diff --git a/front/src/Connexion/LocalUserStore.ts b/front/src/Connexion/LocalUserStore.ts index a95618ba..ac57c3c7 100644 --- a/front/src/Connexion/LocalUserStore.ts +++ b/front/src/Connexion/LocalUserStore.ts @@ -122,7 +122,7 @@ class LocalUserStore { setLastRoomUrl(roomUrl: string): void { localStorage.setItem(lastRoomUrl, roomUrl.toString()); - if ('caches' in window) { + if ("caches" in window) { caches.open(cacheAPIIndex).then((cache) => { const stringResponse = new Response(JSON.stringify({ roomUrl })); cache.put(`/${lastRoomUrl}`, stringResponse); @@ -135,7 +135,7 @@ class LocalUserStore { ); } getLastRoomUrlCacheApi(): Promise { - if (!('caches' in window)) { + if (!("caches" in window)) { return Promise.resolve(undefined); } return caches.open(cacheAPIIndex).then((cache) => { diff --git a/front/src/Phaser/Game/GameMap.ts b/front/src/Phaser/Game/GameMap.ts index 17740874..8fe0e329 100644 --- a/front/src/Phaser/Game/GameMap.ts +++ b/front/src/Phaser/Game/GameMap.ts @@ -12,8 +12,7 @@ export type PropertyChangeCallback = ( export type layerChangeCallback = ( layersChangedByAction: Array, - allLayersOnNewPosition: Array, - + allLayersOnNewPosition: Array ) => void; /** @@ -81,7 +80,7 @@ export class GameMap { } private getLayersByKey(key: number): Array { - return this.flatLayers.filter(flatLayer => flatLayer.type === 'tilelayer' && flatLayer.data[key] !== 0); + return this.flatLayers.filter((flatLayer) => flatLayer.type === "tilelayer" && flatLayer.data[key] !== 0); } /** @@ -134,14 +133,13 @@ export class GameMap { const enterLayers = new Set(layersByNewKey); const leaveLayers = new Set(layersByOldKey); - enterLayers.forEach(layer => { + enterLayers.forEach((layer) => { if (leaveLayers.has(layer)) { leaveLayers.delete(layer); enterLayers.delete(layer); } }); - if (enterLayers.size > 0) { const layerArray = Array.from(enterLayers); for (const callback of this.enterLayerCallbacks) { diff --git a/front/src/Phaser/Game/GameMapProperties.ts b/front/src/Phaser/Game/GameMapProperties.ts index d13f828a..65ce6ab8 100644 --- a/front/src/Phaser/Game/GameMapProperties.ts +++ b/front/src/Phaser/Game/GameMapProperties.ts @@ -1,37 +1,37 @@ export enum GameMapProperties { - ALLOW_API = 'allowApi', - AUDIO_LOOP = 'audioLoop', - AUDIO_VOLUME = 'audioVolume', - COLLIDES = 'collides', - DEFAULT = 'default', - EXIT_URL = 'exitUrl', - EXIT_SCENE_URL = 'exitSceneUrl', - FONT_FAMILY = 'font-family', - JITSI_ADMIN_ROOM_TAG = 'jitsiRoomAdminTag', - JITSI_CONFIG = 'jitsiConfig', - JITSI_INTERFACE_CONFIG = 'jitsiInterfaceConfig', - JITSI_ROOM = 'jitsiRoom', - JITSI_TRIGGER = 'jitsiTrigger', - JITSI_TRIGGER_MESSAGE = 'jitsiTriggerMessage', - JITSI_URL = 'jitsiUrl', - JITSI_WIDTH = 'jitsiWidth', - NAME = 'name', - OPEN_TAB = 'openTab', - OPEN_WEBSITE = 'openWebsite', - OPEN_WEBSITE_ALLOW_API = 'openWebsiteAllowApi', - OPEN_WEBSITE_POLICY = 'openWebsitePolicy', - OPEN_WEBSITE_WIDTH = 'openWebsiteWidth', - OPEN_WEBSITE_POSITION = 'openWebsitePosition', - OPEN_WEBSITE_TRIGGER = 'openWebsiteTrigger', - OPEN_WEBSITE_TRIGGER_MESSAGE = 'openWebsiteTriggerMessage', - PLAY_AUDIO = 'playAudio', - PLAY_AUDIO_LOOP = 'playAudioLoop', - READABLE_BY = 'readableBy', - SCRIPT = 'script', - SILENT = 'silent', - START = 'start', - START_LAYER = 'startLayer', - URL = 'url', - WRITABLE_BY = 'writableBy', - ZONE = 'zone', + ALLOW_API = "allowApi", + AUDIO_LOOP = "audioLoop", + AUDIO_VOLUME = "audioVolume", + COLLIDES = "collides", + DEFAULT = "default", + EXIT_URL = "exitUrl", + EXIT_SCENE_URL = "exitSceneUrl", + FONT_FAMILY = "font-family", + JITSI_ADMIN_ROOM_TAG = "jitsiRoomAdminTag", + JITSI_CONFIG = "jitsiConfig", + JITSI_INTERFACE_CONFIG = "jitsiInterfaceConfig", + JITSI_ROOM = "jitsiRoom", + JITSI_TRIGGER = "jitsiTrigger", + JITSI_TRIGGER_MESSAGE = "jitsiTriggerMessage", + JITSI_URL = "jitsiUrl", + JITSI_WIDTH = "jitsiWidth", + NAME = "name", + OPEN_TAB = "openTab", + OPEN_WEBSITE = "openWebsite", + OPEN_WEBSITE_ALLOW_API = "openWebsiteAllowApi", + OPEN_WEBSITE_POLICY = "openWebsitePolicy", + OPEN_WEBSITE_WIDTH = "openWebsiteWidth", + OPEN_WEBSITE_POSITION = "openWebsitePosition", + OPEN_WEBSITE_TRIGGER = "openWebsiteTrigger", + OPEN_WEBSITE_TRIGGER_MESSAGE = "openWebsiteTriggerMessage", + PLAY_AUDIO = "playAudio", + PLAY_AUDIO_LOOP = "playAudioLoop", + READABLE_BY = "readableBy", + SCRIPT = "script", + SILENT = "silent", + START = "start", + START_LAYER = "startLayer", + URL = "url", + WRITABLE_BY = "writableBy", + ZONE = "zone", } diff --git a/front/src/Phaser/Game/GameMapPropertiesListener.ts b/front/src/Phaser/Game/GameMapPropertiesListener.ts index 5a033d5c..0261ffb7 100644 --- a/front/src/Phaser/Game/GameMapPropertiesListener.ts +++ b/front/src/Phaser/Game/GameMapPropertiesListener.ts @@ -4,10 +4,8 @@ import { scriptUtils } from "../../Api/ScriptUtils"; import type { CoWebsite } from "../../WebRtc/CoWebsiteManager"; import { coWebsiteManager } from "../../WebRtc/CoWebsiteManager"; import { layoutManagerActionStore } from "../../Stores/LayoutManagerStore"; -import { get } from 'svelte/store'; -import { - ON_ACTION_TRIGGER_BUTTON, -} from "../../WebRtc/LayoutManager"; +import { get } from "svelte/store"; +import { ON_ACTION_TRIGGER_BUTTON } from "../../WebRtc/LayoutManager"; import type { ITiledMapLayer } from "../Map/ITiledMap"; import { GameMapProperties } from "./GameMapProperties"; @@ -18,8 +16,8 @@ enum OpenCoWebsiteState { } interface OpenCoWebsite { - coWebsite: CoWebsite | undefined, - state: OpenCoWebsiteState + coWebsite: CoWebsite | undefined; + state: OpenCoWebsiteState; } export class GameMapPropertiesListener { @@ -53,10 +51,10 @@ export class GameMapPropertiesListener { } }); - // Open a new co-website by the property. + // Open a new co-website by the property. this.gameMap.onEnterLayer((newLayers) => { const handler = () => { - newLayers.forEach(layer => { + newLayers.forEach((layer) => { if (!layer.properties) { return; } @@ -69,8 +67,8 @@ export class GameMapPropertiesListener { let websiteTriggerProperty: string | undefined; let websiteTriggerMessageProperty: string | undefined; - layer.properties.forEach(property => { - switch(property.name) { + layer.properties.forEach((property) => { + switch (property.name) { case GameMapProperties.OPEN_WEBSITE: openWebsiteProperty = property.value as string | undefined; break; @@ -111,26 +109,28 @@ export class GameMapPropertiesListener { }); const openWebsiteFunction = () => { - coWebsiteManager.loadCoWebsite( - openWebsiteProperty as string, - this.scene.MapUrlFile, - allowApiProperty, - websitePolicyProperty, - websiteWidthProperty, - websitePositionProperty, - ).then(coWebsite => { - const coWebsiteOpen = this.coWebsitesOpenByLayer.get(layer); - if (coWebsiteOpen && coWebsiteOpen.state === OpenCoWebsiteState.MUST_BE_CLOSE) { - coWebsiteManager.closeCoWebsite(coWebsite); - this.coWebsitesOpenByLayer.delete(layer); - this.coWebsitesActionTriggerByLayer.delete(layer); - } else { - this.coWebsitesOpenByLayer.set(layer, { - coWebsite, - state: OpenCoWebsiteState.OPENED - }); - } - }); + coWebsiteManager + .loadCoWebsite( + openWebsiteProperty as string, + this.scene.MapUrlFile, + allowApiProperty, + websitePolicyProperty, + websiteWidthProperty, + websitePositionProperty + ) + .then((coWebsite) => { + const coWebsiteOpen = this.coWebsitesOpenByLayer.get(layer); + if (coWebsiteOpen && coWebsiteOpen.state === OpenCoWebsiteState.MUST_BE_CLOSE) { + coWebsiteManager.closeCoWebsite(coWebsite); + this.coWebsitesOpenByLayer.delete(layer); + this.coWebsitesActionTriggerByLayer.delete(layer); + } else { + this.coWebsitesOpenByLayer.set(layer, { + coWebsite, + state: OpenCoWebsiteState.OPENED, + }); + } + }); layoutManagerActionStore.removeAction(actionUuid); }; @@ -161,7 +161,7 @@ export class GameMapPropertiesListener { // Close opened co-websites on leave the layer who contain the property. this.gameMap.onLeaveLayer((oldLayers) => { const handler = () => { - oldLayers.forEach(layer => { + oldLayers.forEach((layer) => { if (!layer.properties) { return; } @@ -169,8 +169,8 @@ export class GameMapPropertiesListener { let openWebsiteProperty: string | undefined; let websiteTriggerProperty: string | undefined; - layer.properties.forEach(property => { - switch(property.name) { + layer.properties.forEach((property) => { + switch (property.name) { case GameMapProperties.OPEN_WEBSITE: openWebsiteProperty = property.value as string | undefined; break; @@ -216,9 +216,10 @@ export class GameMapPropertiesListener { return; } - const action = actionStore && actionStore.length > 0 ? - actionStore.find(action => action.uuid === actionTriggerUuid) : undefined; - + const action = + actionStore && actionStore.length > 0 + ? actionStore.find((action) => action.uuid === actionTriggerUuid) + : undefined; if (action) { layoutManagerActionStore.removeAction(actionTriggerUuid); diff --git a/front/src/Stores/LayoutManagerStore.ts b/front/src/Stores/LayoutManagerStore.ts index 063d45a7..e92cd3c4 100644 --- a/front/src/Stores/LayoutManagerStore.ts +++ b/front/src/Stores/LayoutManagerStore.ts @@ -9,9 +9,7 @@ export interface LayoutManagerAction { userInputManager: UserInputManager | undefined; } - function createLayoutManagerAction() { - const { subscribe, set, update } = writable([]); return { diff --git a/front/src/WebRtc/JitsiFactory.ts b/front/src/WebRtc/JitsiFactory.ts index df647f55..0f205f47 100644 --- a/front/src/WebRtc/JitsiFactory.ts +++ b/front/src/WebRtc/JitsiFactory.ts @@ -141,51 +141,55 @@ class JitsiFactory { jitsiUrl?: string, jitsiWidth?: number ): void { - coWebsiteManager.addCoWebsite(async (cowebsiteDiv) => { - // Jitsi meet external API maintains some data in local storage - // which is sent via the appData URL parameter when joining a - // conference. Problem is that this data grows indefinitely. Thus - // after some time the URLs get so huge that loading the iframe - // becomes slow and eventually breaks completely. Thus lets just - // clear jitsi local storage before starting a new conference. - window.localStorage.removeItem("jitsiLocalStorage"); + coWebsiteManager.addCoWebsite( + async (cowebsiteDiv) => { + // Jitsi meet external API maintains some data in local storage + // which is sent via the appData URL parameter when joining a + // conference. Problem is that this data grows indefinitely. Thus + // after some time the URLs get so huge that loading the iframe + // becomes slow and eventually breaks completely. Thus lets just + // clear jitsi local storage before starting a new conference. + window.localStorage.removeItem("jitsiLocalStorage"); - const domain = jitsiUrl || JITSI_URL; - if (domain === undefined) { - throw new Error("Missing JITSI_URL environment variable or jitsiUrl parameter in the map."); - } - await this.loadJitsiScript(domain); - - const options: JitsiOptions = { - roomName: roomName, - jwt: jwt, - width: "100%", - height: "100%", - parentNode: cowebsiteDiv, - configOverwrite: mergeConfig(config), - interfaceConfigOverwrite: { ...defaultInterfaceConfig, ...interfaceConfig }, - }; - if (!options.jwt) { - delete options.jwt; - } - - return new Promise((resolve, reject) => { - const doResolve = (): void => { - const iframe = cowebsiteDiv.querySelector('[id*="jitsi" i]'); - if (iframe === null) { - throw new Error("Could not find Jitsi Iframe"); - } - resolve(iframe); + const domain = jitsiUrl || JITSI_URL; + if (domain === undefined) { + throw new Error("Missing JITSI_URL environment variable or jitsiUrl parameter in the map."); } - options.onload = () => doResolve(); //we want for the iframe to be loaded before triggering animations. - setTimeout(() => doResolve(), 2000); //failsafe in case the iframe is deleted before loading or too long to load - this.jitsiApi = new window.JitsiMeetExternalAPI(domain, options); - this.jitsiApi.executeCommand("displayName", playerName); + await this.loadJitsiScript(domain); - this.jitsiApi.addListener("audioMuteStatusChanged", this.audioCallback); - this.jitsiApi.addListener("videoMuteStatusChanged", this.videoCallback); - }); - }, jitsiWidth, 0); + const options: JitsiOptions = { + roomName: roomName, + jwt: jwt, + width: "100%", + height: "100%", + parentNode: cowebsiteDiv, + configOverwrite: mergeConfig(config), + interfaceConfigOverwrite: { ...defaultInterfaceConfig, ...interfaceConfig }, + }; + if (!options.jwt) { + delete options.jwt; + } + + return new Promise((resolve, reject) => { + const doResolve = (): void => { + const iframe = cowebsiteDiv.querySelector('[id*="jitsi" i]'); + if (iframe === null) { + throw new Error("Could not find Jitsi Iframe"); + } + resolve(iframe); + }; + options.onload = () => doResolve(); //we want for the iframe to be loaded before triggering animations. + setTimeout(() => doResolve(), 2000); //failsafe in case the iframe is deleted before loading or too long to load + this.jitsiApi = new window.JitsiMeetExternalAPI(domain, options); + this.jitsiApi.executeCommand("displayName", playerName); + + this.jitsiApi.addListener("audioMuteStatusChanged", this.audioCallback); + this.jitsiApi.addListener("videoMuteStatusChanged", this.videoCallback); + }); + }, + jitsiWidth, + 0 + ); } public stop() { From 07ba532c5e256925a0b3206a4daf6f597f41fa8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Wed, 24 Nov 2021 15:31:17 +0100 Subject: [PATCH 10/18] Prettier fixes on front --- front/src/Phaser/Components/Loader.ts | 24 +++++++++++++------ .../src/Phaser/Login/SelectCharacterScene.ts | 2 +- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/front/src/Phaser/Components/Loader.ts b/front/src/Phaser/Components/Loader.ts index 0534aa91..e013e758 100644 --- a/front/src/Phaser/Components/Loader.ts +++ b/front/src/Phaser/Components/Loader.ts @@ -13,11 +13,10 @@ export class Loader { private progressContainer!: Phaser.GameObjects.Graphics; private progress!: Phaser.GameObjects.Graphics; private progressAmount: number = 0; - private logo: Phaser.GameObjects.Image|undefined; + private logo: Phaser.GameObjects.Image | undefined; private loadingText: Phaser.GameObjects.Text | null = null; - public constructor(private scene: Phaser.Scene) { - } + public constructor(private scene: Phaser.Scene) {} public addLoader(): void { // If there is nothing to load, do not display the loader. @@ -30,11 +29,19 @@ export class Loader { const promiseLoadLogoTexture = new Promise((res) => { if (this.scene.load.textureManager.exists(LogoNameIndex)) { return res( - this.logo = this.scene.add.image(this.scene.game.renderer.width / 2, this.scene.game.renderer.height / 2 - 150, LogoNameIndex) + (this.logo = this.scene.add.image( + this.scene.game.renderer.width / 2, + this.scene.game.renderer.height / 2 - 150, + LogoNameIndex + )) ); } else { //add loading if logo image is not ready - this.loadingText = this.scene.add.text(this.scene.game.renderer.width / 2, this.scene.game.renderer.height / 2 - 50, TextName); + this.loadingText = this.scene.add.text( + this.scene.game.renderer.width / 2, + this.scene.game.renderer.height / 2 - 50, + TextName + ); } this.scene.load.spritesheet(LogoNameIndex, LogoResource, LogoFrame); this.scene.load.once(`filecomplete-spritesheet-${LogoNameIndex}`, () => { @@ -42,7 +49,11 @@ export class Loader { this.loadingText.destroy(); } return res( - this.logo = this.scene.add.image(this.scene.game.renderer.width / 2, this.scene.game.renderer.height / 2 - 150, LogoNameIndex) + (this.logo = this.scene.add.image( + this.scene.game.renderer.width / 2, + this.scene.game.renderer.height / 2 - 150, + LogoNameIndex + )) ); }); }); @@ -72,7 +83,6 @@ export class Loader { }); } - public removeLoader(): void { if (this.scene.load.textureManager.exists(LogoNameIndex)) { this.scene.load.textureManager.remove(LogoNameIndex); diff --git a/front/src/Phaser/Login/SelectCharacterScene.ts b/front/src/Phaser/Login/SelectCharacterScene.ts index d9861b20..64fa9791 100644 --- a/front/src/Phaser/Login/SelectCharacterScene.ts +++ b/front/src/Phaser/Login/SelectCharacterScene.ts @@ -4,7 +4,7 @@ import { EnableCameraSceneName } from "./EnableCameraScene"; import { CustomizeSceneName } from "./CustomizeScene"; import { localUserStore } from "../../Connexion/LocalUserStore"; import { loadAllDefaultModels } from "../Entity/PlayerTexturesLoadingManager"; -import { Loader} from "../Components/Loader"; +import { Loader } from "../Components/Loader"; import type { BodyResourceDescriptionInterface } from "../Entity/PlayerTextures"; import { AbstractCharacterScene } from "./AbstractCharacterScene"; import { areCharacterLayersValid } from "../../Connexion/LocalUser"; From 5c3036e18bf13dd5d8e3ee1dba794e54d13dfba2 Mon Sep 17 00:00:00 2001 From: Alexis Faizeau Date: Wed, 24 Nov 2021 15:43:01 +0100 Subject: [PATCH 11/18] Display a default skin on remote player entity --- front/src/Phaser/Entity/Character.ts | 4 ++++ .../Phaser/Entity/PlayerTexturesLoadingManager.ts | 12 +++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/front/src/Phaser/Entity/Character.ts b/front/src/Phaser/Entity/Character.ts index 7df18fcd..1211a52d 100644 --- a/front/src/Phaser/Entity/Character.ts +++ b/front/src/Phaser/Entity/Character.ts @@ -128,6 +128,10 @@ export abstract class Character extends Container { } public addTextures(textures: string[], frame?: string | number): void { + if (textures.length < 1) { + throw new TextureError("no texture given"); + } + for (const texture of textures) { if (this.scene && !this.scene.textures.exists(texture)) { throw new TextureError("texture not found"); diff --git a/front/src/Phaser/Entity/PlayerTexturesLoadingManager.ts b/front/src/Phaser/Entity/PlayerTexturesLoadingManager.ts index 92954bfb..edaeb5b8 100644 --- a/front/src/Phaser/Entity/PlayerTexturesLoadingManager.ts +++ b/front/src/Phaser/Entity/PlayerTexturesLoadingManager.ts @@ -69,13 +69,11 @@ export const lazyLoadPlayerCharacterTextures = ( } //If the loading fail, we render the default model instead. - return returnPromise - .then((keys) => - keys.map((key) => { - return typeof key !== "string" ? key.name : key; - }) - ) - .catch(() => lazyLoadPlayerCharacterTextures(loadPlugin, ["color_22", "eyes_23"])); + return returnPromise.then((keys) => + keys.map((key) => { + return typeof key !== "string" ? key.name : key; + }) + ); }; export const getRessourceDescriptor = ( From b02c09fc7bf794b31fb0b5288a9ec0b5a5647a76 Mon Sep 17 00:00:00 2001 From: Gregoire Parant Date: Wed, 24 Nov 2021 15:49:45 +0100 Subject: [PATCH 12/18] Clean token auth of url params Signed-off-by: Gregoire Parant --- front/src/Connexion/ConnectionManager.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/front/src/Connexion/ConnectionManager.ts b/front/src/Connexion/ConnectionManager.ts index ffd91d39..a8b172e6 100644 --- a/front/src/Connexion/ConnectionManager.ts +++ b/front/src/Connexion/ConnectionManager.ts @@ -84,7 +84,8 @@ class ConnectionManager { if (token) { this.authToken = token; localUserStore.setAuthToken(token); - //token was saved, clear url + + //clean token of url urlParams.delete("token"); } @@ -95,8 +96,6 @@ class ConnectionManager { } urlManager.pushRoomIdToUrl(this._currentRoom); } else if (connexionType === GameConnexionTypes.jwt) { - const urlParams = new URLSearchParams(window.location.search); - if (!token) { const code = urlParams.get("code"); const state = urlParams.get("state"); @@ -139,7 +138,7 @@ class ConnectionManager { "//" + window.location.host + roomUrl + - window.location.search + + urlParams.toString() + //use urlParams because the token param must be deleted window.location.hash ) ); @@ -169,7 +168,7 @@ class ConnectionManager { "//" + window.location.host + window.location.pathname + - window.location.search + + urlParams.toString() + //use urlParams because the token param must be deleted window.location.hash; } @@ -218,8 +217,6 @@ class ConnectionManager { analyticsClient.identifyUser(this.localUser.uuid, this.localUser.email); } - //clean history with new URL - window.history.pushState({}, document.title, window.location.pathname); this.serviceWorker = new _ServiceWorker(); return Promise.resolve(this._currentRoom); } From 6e6cdc7bdedbfd9af84c442ac6e89c56abaed69b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Wed, 24 Nov 2021 16:20:07 +0100 Subject: [PATCH 13/18] Revert "Improving log messages" --- back/.eslintrc.json | 1 - back/package.json | 3 +- back/server.ts | 13 +- back/src/Model/GameRoom.ts | 11 +- back/src/RoomManager.ts | 41 +++-- back/src/Server/server/formdata.ts | 8 +- back/src/Services/CpuTracker.ts | 13 +- back/src/Services/Logger.ts | 16 -- back/src/Services/MapFetcher.ts | 3 +- back/src/Services/MessageHelpers.ts | 11 +- back/src/Services/RedisClient.ts | 3 +- .../Repository/VariablesRepository.ts | 3 +- back/src/Services/SocketManager.ts | 35 ++-- back/src/Services/VariablesManager.ts | 5 +- back/tsconfig.json | 2 +- back/yarn.lock | 164 +----------------- front/src/Administration/AnalyticsClient.ts | 74 ++++---- front/src/Api/IframeListener.ts | 2 +- front/src/Connexion/LocalUserStore.ts | 4 +- front/src/Phaser/Components/Loader.ts | 24 +-- .../src/Phaser/Login/SelectCharacterScene.ts | 2 +- package.json | 3 +- pusher/package.json | 3 +- pusher/server.ts | 4 +- pusher/src/Controller/AdminController.ts | 9 +- .../src/Controller/AuthenticateController.ts | 25 ++- pusher/src/Controller/BaseController.ts | 7 +- pusher/src/Controller/IoSocketController.ts | 27 ++- pusher/src/Controller/MapController.ts | 7 +- pusher/src/Model/PositionDispatcher.ts | 3 +- pusher/src/Model/Zone.ts | 3 +- pusher/src/Server/server/formdata.ts | 3 +- pusher/src/Services/CpuTracker.ts | 13 +- pusher/src/Services/IoSocketHelpers.ts | 3 +- pusher/src/Services/Logger.ts | 16 -- pusher/src/Services/SocketManager.ts | 49 +++--- pusher/yarn.lock | 164 +----------------- yarn.lock | 7 +- 38 files changed, 203 insertions(+), 581 deletions(-) delete mode 100644 back/src/Services/Logger.ts delete mode 100644 pusher/src/Services/Logger.ts diff --git a/back/.eslintrc.json b/back/.eslintrc.json index 0b5e39da..3aab37d9 100644 --- a/back/.eslintrc.json +++ b/back/.eslintrc.json @@ -25,7 +25,6 @@ ], "rules": { "no-unused-vars": "off", - "@typescript-eslint/no-floating-promises": "error", "@typescript-eslint/no-explicit-any": "error" } } diff --git a/back/package.json b/back/package.json index 817295ce..aacd0c96 100644 --- a/back/package.json +++ b/back/package.json @@ -55,8 +55,7 @@ "query-string": "^6.13.3", "redis": "^3.1.2", "uWebSockets.js": "uNetworking/uWebSockets.js#v18.5.0", - "uuidv4": "^6.0.7", - "winston": "^3.3.3" + "uuidv4": "^6.0.7" }, "devDependencies": { "@types/busboy": "^0.2.3", diff --git a/back/server.ts b/back/server.ts index 1026bc3e..8d761719 100644 --- a/back/server.ts +++ b/back/server.ts @@ -1,16 +1,15 @@ // lib/server.ts import App from "./src/App"; import grpc from "grpc"; -import { roomManager } from "./src/RoomManager"; -import { IRoomManagerServer, RoomManagerService } from "./src/Messages/generated/messages_grpc_pb"; -import { HTTP_PORT, GRPC_PORT } from "./src/Enum/EnvironmentVariable"; -import log from "./src/Services/Logger"; +import {roomManager} from "./src/RoomManager"; +import {IRoomManagerServer, RoomManagerService} from "./src/Messages/generated/messages_grpc_pb"; +import {HTTP_PORT, GRPC_PORT} from "./src/Enum/EnvironmentVariable"; -App.listen(HTTP_PORT, () => log.info(`WorkAdventure HTTP API starting on port %d!`, HTTP_PORT)); +App.listen(HTTP_PORT, () => console.log(`WorkAdventure HTTP API starting on port %d!`, HTTP_PORT)) const server = new grpc.Server(); server.addService(RoomManagerService, roomManager); -server.bind("0.0.0.0:" + GRPC_PORT, grpc.ServerCredentials.createInsecure()); +server.bind('0.0.0.0:'+GRPC_PORT, grpc.ServerCredentials.createInsecure()); server.start(); -log.info("WorkAdventure HTTP/2 API starting on port %d!", GRPC_PORT); +console.log('WorkAdventure HTTP/2 API starting on port %d!', GRPC_PORT); diff --git a/back/src/Model/GameRoom.ts b/back/src/Model/GameRoom.ts index c990e5cf..5c114f19 100644 --- a/back/src/Model/GameRoom.ts +++ b/back/src/Model/GameRoom.ts @@ -27,7 +27,6 @@ import { ADMIN_API_URL } from "../Enum/EnvironmentVariable"; import { LocalUrlError } from "../Services/LocalUrlError"; import { emitErrorOnRoomSocket } from "../Services/MessageHelpers"; import { VariableError } from "../Services/VariableError"; -import log from "../Services/Logger"; export type ConnectCallback = (user: User, group: Group) => void; export type DisconnectCallback = (user: User, group: Group) => void; @@ -153,7 +152,7 @@ export class GameRoom { public leave(user: User) { const userObj = this.users.get(user.id); if (userObj === undefined) { - log.warn("User ", user.id, "does not belong to this game room! It should!"); + console.warn("User ", user.id, "does not belong to this game room! It should!"); } if (userObj !== undefined && typeof userObj.group !== "undefined") { this.leaveGroup(userObj); @@ -445,7 +444,7 @@ export class GameRoom { const match = /\/_\/[^/]+\/(.+)/.exec(roomUrlObj.pathname); if (!match) { - log.error("Unexpected room URL", roomUrl); + console.error("Unexpected room URL", roomUrl); throw new Error('Unexpected room URL "' + roomUrl + '"'); } @@ -461,7 +460,7 @@ export class GameRoom { const result = await adminApi.fetchMapDetails(roomUrl); if (!isMapDetailsData(result)) { - log.error("Unexpected room details received from server", result); + console.error("Unexpected room details received from server", result); throw new Error("Unexpected room details received from server"); } return result; @@ -520,9 +519,7 @@ export class GameRoom { for (const roomListener of this.roomListeners) { emitErrorOnRoomSocket( roomListener, - "Your map '" + - this.mapUrl + - "' does not seem accessible from the WorkAdventure servers. Is it behind a firewall or a proxy? Your map should be accessible from the WorkAdventure servers. If you use the scripting API in this map, please be aware that server-side checks and variable persistence is disabled." + "Your map does not seem accessible from the WorkAdventure servers. Is it behind a firewall or a proxy? Your map should be accessible from the WorkAdventure servers. If you use the scripting API in this map, please be aware that server-side checks and variable persistence is disabled." ); } }, 1000); diff --git a/back/src/RoomManager.ts b/back/src/RoomManager.ts index 65a71e02..8dbde018 100644 --- a/back/src/RoomManager.ts +++ b/back/src/RoomManager.ts @@ -31,7 +31,6 @@ import { User, UserSocket } from "./Model/User"; import { GameRoom } from "./Model/GameRoom"; import Debug from "debug"; import { Admin } from "./Model/Admin"; -import log from "./Services/Logger"; const debug = Debug("roommanager"); @@ -41,7 +40,7 @@ export type RoomSocket = ServerWritableStream { - log.info("joinRoom called"); + console.log("joinRoom called"); let room: GameRoom | null = null; let user: User | null = null; @@ -132,11 +131,11 @@ const roomManager: IRoomManagerServer = { } } } catch (e) { - log.error(e); + console.error(e); emitError(call, e); call.end(); } - })().catch((e) => log.error(e)); + })().catch((e) => console.error(e)); }); call.on("end", () => { @@ -150,7 +149,7 @@ const roomManager: IRoomManagerServer = { }); call.on("error", (err: Error) => { - log.error("An error occurred in joinRoom stream:", err); + console.error("An error occurred in joinRoom stream:", err); }); }, @@ -168,7 +167,7 @@ const roomManager: IRoomManagerServer = { debug("listenZone cancelled"); socketManager .removeZoneListener(call, zoneMessage.getRoomid(), zoneMessage.getX(), zoneMessage.getY()) - .catch((e) => log.error(e)); + .catch((e) => console.error(e)); call.end(); }); @@ -176,12 +175,12 @@ const roomManager: IRoomManagerServer = { debug("listenZone connection closed"); socketManager .removeZoneListener(call, zoneMessage.getRoomid(), zoneMessage.getX(), zoneMessage.getY()) - .catch((e) => log.error(e)); + .catch((e) => console.error(e)); }).on("error", (e) => { - log.error("An error occurred in listenZone stream:", e); + console.error("An error occurred in listenZone stream:", e); socketManager .removeZoneListener(call, zoneMessage.getRoomid(), zoneMessage.getX(), zoneMessage.getY()) - .catch((e) => log.error(e)); + .catch((e) => console.error(e)); call.end(); }); }, @@ -196,22 +195,22 @@ const roomManager: IRoomManagerServer = { call.on("cancelled", () => { debug("listenRoom cancelled"); - socketManager.removeRoomListener(call, roomMessage.getRoomid()).catch((e) => log.error(e)); + socketManager.removeRoomListener(call, roomMessage.getRoomid()).catch((e) => console.error(e)); call.end(); }); call.on("close", () => { debug("listenRoom connection closed"); - socketManager.removeRoomListener(call, roomMessage.getRoomid()).catch((e) => log.error(e)); + socketManager.removeRoomListener(call, roomMessage.getRoomid()).catch((e) => console.error(e)); }).on("error", (e) => { - log.error("An error occurred in listenRoom stream:", e); - socketManager.removeRoomListener(call, roomMessage.getRoomid()).catch((e) => log.error(e)); + console.error("An error occurred in listenRoom stream:", e); + socketManager.removeRoomListener(call, roomMessage.getRoomid()).catch((e) => console.error(e)); call.end(); }); }, adminRoom(call: AdminSocket): void { - log.info("adminRoom called"); + console.log("adminRoom called"); const admin = new Admin(call); let room: GameRoom | null = null; @@ -226,7 +225,7 @@ const roomManager: IRoomManagerServer = { .then((gameRoom: GameRoom) => { room = gameRoom; }) - .catch((e) => log.error(e)); + .catch((e) => console.error(e)); } else { throw new Error("The first message sent MUST be of type JoinRoomMessage"); } @@ -247,13 +246,13 @@ const roomManager: IRoomManagerServer = { }); call.on("error", (err: Error) => { - log.error("An error occurred in joinAdminRoom stream:", err); + console.error("An error occurred in joinAdminRoom stream:", err); }); }, sendAdminMessage(call: ServerUnaryCall, callback: sendUnaryData): void { socketManager .sendAdminMessage(call.request.getRoomid(), call.request.getRecipientuuid(), call.request.getMessage()) - .catch((e) => log.error(e)); + .catch((e) => console.error(e)); callback(null, new EmptyMessage()); }, @@ -266,7 +265,7 @@ const roomManager: IRoomManagerServer = { // FIXME Work in progress socketManager .banUser(call.request.getRoomid(), call.request.getRecipientuuid(), call.request.getMessage()) - .catch((e) => log.error(e)); + .catch((e) => console.error(e)); callback(null, new EmptyMessage()); }, @@ -274,7 +273,7 @@ const roomManager: IRoomManagerServer = { // FIXME: we could improve return message by returning a Success|ErrorMessage message socketManager .sendAdminRoomMessage(call.request.getRoomid(), call.request.getMessage(), call.request.getType()) - .catch((e) => log.error(e)); + .catch((e) => console.error(e)); callback(null, new EmptyMessage()); }, sendWorldFullWarningToRoom( @@ -282,7 +281,7 @@ const roomManager: IRoomManagerServer = { callback: sendUnaryData ): void { // FIXME: we could improve return message by returning a Success|ErrorMessage message - socketManager.dispatchWorldFullWarning(call.request.getRoomid()).catch((e) => log.error(e)); + socketManager.dispatchWorldFullWarning(call.request.getRoomid()).catch((e) => console.error(e)); callback(null, new EmptyMessage()); }, sendRefreshRoomPrompt( @@ -290,7 +289,7 @@ const roomManager: IRoomManagerServer = { callback: sendUnaryData ): void { // FIXME: we could improve return message by returning a Success|ErrorMessage message - socketManager.dispatchRoomRefresh(call.request.getRoomid()).catch((e) => log.error(e)); + socketManager.dispatchRoomRefresh(call.request.getRoomid()).catch((e) => console.error(e)); callback(null, new EmptyMessage()); }, }; diff --git a/back/src/Server/server/formdata.ts b/back/src/Server/server/formdata.ts index a3ef07ee..66e51db4 100644 --- a/back/src/Server/server/formdata.ts +++ b/back/src/Server/server/formdata.ts @@ -2,7 +2,6 @@ import { createWriteStream } from "fs"; import { join, dirname } from "path"; import Busboy from "busboy"; import mkdirp from "mkdirp"; -import log from "../../Services/Logger"; function formData( contType: string, @@ -20,7 +19,7 @@ function formData( filename?: (oldName: string) => string; } = {} ) { - log.info("Enter form data"); + console.log("Enter form data"); options.headers = { "content-type": contType, }; @@ -48,10 +47,7 @@ function formData( if (typeof options.tmpDir === "string") { if (typeof options.filename === "function") filename = options.filename(filename); const fileToSave = join(options.tmpDir, filename); - mkdirp(dirname(fileToSave)).then( - () => {}, - () => {} - ); + mkdirp(dirname(fileToSave)); file.pipe(createWriteStream(fileToSave)); value.filePath = fileToSave; diff --git a/back/src/Services/CpuTracker.ts b/back/src/Services/CpuTracker.ts index 4ff48eb6..3d06ca70 100644 --- a/back/src/Services/CpuTracker.ts +++ b/back/src/Services/CpuTracker.ts @@ -1,5 +1,4 @@ import { CPU_OVERHEAT_THRESHOLD } from "../Enum/EnvironmentVariable"; -import log from "./Logger"; function secNSec2ms(secNSec: Array | number) { if (Array.isArray(secNSec)) { @@ -29,16 +28,16 @@ class CpuTracker { if (!this.overHeating && this.cpuPercent > CPU_OVERHEAT_THRESHOLD) { this.overHeating = true; - log.warn('CPU high threshold alert. Going in "overheat" mode'); + console.warn('CPU high threshold alert. Going in "overheat" mode'); } else if (this.overHeating && this.cpuPercent <= CPU_OVERHEAT_THRESHOLD) { this.overHeating = false; - log.info('CPU is back to normal. Canceling "overheat" mode'); + console.log('CPU is back to normal. Canceling "overheat" mode'); } - /*log.info('elapsed time ms: ', elapTimeMS) - log.info('elapsed user ms: ', elapUserMS) - log.info('elapsed system ms:', elapSystMS) - log.info('cpu percent: ', this.cpuPercent)*/ + /*console.log('elapsed time ms: ', elapTimeMS) + console.log('elapsed user ms: ', elapUserMS) + console.log('elapsed system ms:', elapSystMS) + console.log('cpu percent: ', this.cpuPercent)*/ }, 100); } diff --git a/back/src/Services/Logger.ts b/back/src/Services/Logger.ts deleted file mode 100644 index e19f60d1..00000000 --- a/back/src/Services/Logger.ts +++ /dev/null @@ -1,16 +0,0 @@ -import * as winston from "winston"; - -const logger = winston.createLogger({ - transports: [ - new winston.transports.Console({ - format: winston.format.combine( - winston.format.colorize(), - winston.format.timestamp(), - winston.format.align(), - winston.format.printf((info) => `${info.timestamp} ${info.level}: ${info.message}`) - ), - }), - ], -}); - -export default logger; diff --git a/back/src/Services/MapFetcher.ts b/back/src/Services/MapFetcher.ts index d2d753ae..15c31517 100644 --- a/back/src/Services/MapFetcher.ts +++ b/back/src/Services/MapFetcher.ts @@ -6,7 +6,6 @@ import { LocalUrlError } from "./LocalUrlError"; import { ITiledMap } from "@workadventure/tiled-map-type-guard"; import { isTiledMap } from "@workadventure/tiled-map-type-guard/dist"; import { STORE_VARIABLES_FOR_LOCAL_MAPS } from "../Enum/EnvironmentVariable"; -import log from "./Logger"; class MapFetcher { async fetchMap(mapUrl: string): Promise { @@ -31,7 +30,7 @@ class MapFetcher { if (!isTiledMap(res.data)) { //TODO fixme //throw new Error("Invalid map format for map " + mapUrl); - log.error("Invalid map format for map " + mapUrl); + console.error("Invalid map format for map " + mapUrl); } return res.data; diff --git a/back/src/Services/MessageHelpers.ts b/back/src/Services/MessageHelpers.ts index 9068881c..606374be 100644 --- a/back/src/Services/MessageHelpers.ts +++ b/back/src/Services/MessageHelpers.ts @@ -9,7 +9,6 @@ import { } from "../Messages/generated/messages_pb"; import { UserSocket } from "_Model/User"; import { RoomSocket, ZoneSocket } from "../RoomManager"; -import log from "./Logger"; export function emitError(Client: UserSocket, message: string): void { const errorMessage = new ErrorMessage(); @@ -21,11 +20,11 @@ export function emitError(Client: UserSocket, message: string): void { //if (!Client.disconnecting) { Client.write(serverToClientMessage); //} - log.warn(message); + console.warn(message); } export function emitErrorOnRoomSocket(Client: RoomSocket, message: string): void { - log.error(message); + console.error(message); const errorMessage = new ErrorMessage(); errorMessage.setMessage(message); @@ -39,11 +38,11 @@ export function emitErrorOnRoomSocket(Client: RoomSocket, message: string): void //if (!Client.disconnecting) { Client.write(batchToPusherMessage); //} - log.warn(message); + console.warn(message); } export function emitErrorOnZoneSocket(Client: ZoneSocket, message: string): void { - log.error(message); + console.error(message); const errorMessage = new ErrorMessage(); errorMessage.setMessage(message); @@ -57,5 +56,5 @@ export function emitErrorOnZoneSocket(Client: ZoneSocket, message: string): void //if (!Client.disconnecting) { Client.write(batchToPusherMessage); //} - log.warn(message); + console.warn(message); } diff --git a/back/src/Services/RedisClient.ts b/back/src/Services/RedisClient.ts index 4737f21e..1f8c1ecd 100644 --- a/back/src/Services/RedisClient.ts +++ b/back/src/Services/RedisClient.ts @@ -1,6 +1,5 @@ import { ClientOpts, createClient, RedisClient } from "redis"; import { REDIS_HOST, REDIS_PASSWORD, REDIS_PORT } from "../Enum/EnvironmentVariable"; -import log from "./Logger"; let redisClient: RedisClient | null = null; @@ -17,7 +16,7 @@ if (REDIS_HOST !== undefined) { redisClient = createClient(config); redisClient.on("error", (err) => { - log.error("Error connecting to Redis:", err); + console.error("Error connecting to Redis:", err); }); } diff --git a/back/src/Services/Repository/VariablesRepository.ts b/back/src/Services/Repository/VariablesRepository.ts index 89bac288..9f668bcf 100644 --- a/back/src/Services/Repository/VariablesRepository.ts +++ b/back/src/Services/Repository/VariablesRepository.ts @@ -2,11 +2,10 @@ import { RedisVariablesRepository } from "./RedisVariablesRepository"; import { redisClient } from "../RedisClient"; import { VoidVariablesRepository } from "./VoidVariablesRepository"; import { VariablesRepositoryInterface } from "./VariablesRepositoryInterface"; -import log from "../../Services/Logger"; let variablesRepository: VariablesRepositoryInterface; if (!redisClient) { - log.warn("WARNING: Redis isnot configured. No variables will be persisted."); + console.warn("WARNING: Redis isnot configured. No variables will be persisted."); variablesRepository = new VoidVariablesRepository(); } else { variablesRepository = new RedisVariablesRepository(redisClient); diff --git a/back/src/Services/SocketManager.ts b/back/src/Services/SocketManager.ts index 910dc26a..5efae800 100644 --- a/back/src/Services/SocketManager.ts +++ b/back/src/Services/SocketManager.ts @@ -56,7 +56,6 @@ import { Zone } from "_Model/Zone"; import Debug from "debug"; import { Admin } from "_Model/Admin"; import crypto from "crypto"; -import log from "./Logger"; const debug = Debug("sockermanager"); @@ -90,7 +89,7 @@ export class SocketManager { const { room, user } = await this.joinRoom(socket, joinRoomMessage); if (!socket.writable) { - log.warn("Socket was aborted"); + console.warn("Socket was aborted"); return { room, user, @@ -157,7 +156,7 @@ export class SocketManager { name: playerDetailsMessage.getName(), characterLayers: playerDetailsMessage.getCharacterlayersList() }; - //log.info(SocketIoEvent.SET_PLAYER_DETAILS, playerDetails); + //console.log(SocketIoEvent.SET_PLAYER_DETAILS, playerDetails); if (!isSetPlayerDetailsMessage(playerDetails)) { emitError(client, 'Invalid SET_PLAYER_DETAILS message received: '); return; @@ -193,7 +192,7 @@ export class SocketManager { //send only at user const remoteUser = room.getUsers().get(data.getReceiverid()); if (remoteUser === undefined) { - log.warn( + console.warn( "While exchanging a WebRTC signal: client with id ", data.getReceiverid(), " does not exist. This might be a race condition." @@ -223,7 +222,7 @@ export class SocketManager { //send only at user const remoteUser = room.getUsers().get(data.getReceiverid()); if (remoteUser === undefined) { - log.warn( + console.warn( "While exchanging a WEBRTC_SCREEN_SHARING signal: client with id ", data.getReceiverid(), " does not exist. This might be a race condition." @@ -261,7 +260,7 @@ export class SocketManager { } } finally { clientEventsEmitter.emitClientLeave(user.uuid, room.roomUrl); - log.info("A user left"); + console.log("A user left"); } } @@ -309,7 +308,7 @@ export class SocketManager { const user = room.join(socket, joinRoomMessage); clientEventsEmitter.emitClientJoin(user.uuid, roomId); - log.info(new Date().toISOString() + " user '" + user.uuid + "' joined room '" + roomId + "'"); + console.log(new Date().toISOString() + " A user joined"); return { room, user }; } @@ -338,7 +337,7 @@ export class SocketManager { } else if (thing instanceof Group) { this.emitCreateUpdateGroupEvent(listener, fromZone, thing); } else { - log.error("Unexpected type for Movable."); + console.error("Unexpected type for Movable."); } } @@ -353,11 +352,11 @@ export class SocketManager { emitZoneMessage(subMessage, listener); //listener.emitInBatch(subMessage); - //log.info("Sending USER_MOVED event"); + //console.log("Sending USER_MOVED event"); } else if (thing instanceof Group) { this.emitCreateUpdateGroupEvent(listener, null, thing); } else { - log.error("Unexpected type for Movable."); + console.error("Unexpected type for Movable."); } } @@ -367,7 +366,7 @@ export class SocketManager { } else if (thing instanceof Group) { this.emitDeleteGroupEvent(listener, thing.getId(), newZone); } else { - log.error("Unexpected type for Movable."); + console.error("Unexpected type for Movable."); } } @@ -636,7 +635,7 @@ export class SocketManager { batchMessage.addPayload(subMessage); } else { - log.error("Unexpected type for Movable returned by setViewport"); + console.error("Unexpected type for Movable returned by setViewport"); } } @@ -694,7 +693,7 @@ export class SocketManager { public async sendAdminMessage(roomId: string, recipientUuid: string, message: string): Promise { const room = await this.roomsPromises.get(roomId); if (!room) { - log.error( + console.error( "In sendAdminMessage, could not find room with id '" + roomId + "'. Maybe the room was closed a few milliseconds ago and there was a race condition?" @@ -704,7 +703,7 @@ export class SocketManager { const recipients = room.getUsersByUuid(recipientUuid); if (recipients.length === 0) { - log.error( + console.error( "In sendAdminMessage, could not find user with id '" + recipientUuid + "'. Maybe the user left the room a few milliseconds ago and there was a race condition?" @@ -727,7 +726,7 @@ export class SocketManager { public async banUser(roomId: string, recipientUuid: string, message: string): Promise { const room = await this.roomsPromises.get(roomId); if (!room) { - log.error( + console.error( "In banUser, could not find room with id '" + roomId + "'. Maybe the room was closed a few milliseconds ago and there was a race condition?" @@ -737,7 +736,7 @@ export class SocketManager { const recipients = room.getUsersByUuid(recipientUuid); if (recipients.length === 0) { - log.error( + console.error( "In banUser, could not find user with id '" + recipientUuid + "'. Maybe the user left the room a few milliseconds ago and there was a race condition?" @@ -766,7 +765,7 @@ export class SocketManager { const room = await this.roomsPromises.get(roomId); if (!room) { //todo: this should cause the http call to return a 500 - log.error( + console.error( "In sendAdminRoomMessage, could not find room with id '" + roomId + "'. Maybe the room was closed a few milliseconds ago and there was a race condition?" @@ -790,7 +789,7 @@ export class SocketManager { const room = await this.roomsPromises.get(roomId); if (!room) { //todo: this should cause the http call to return a 500 - log.error( + console.error( "In dispatchWorldFullWarning, could not find room with id '" + roomId + "'. Maybe the room was closed a few milliseconds ago and there was a race condition?" diff --git a/back/src/Services/VariablesManager.ts b/back/src/Services/VariablesManager.ts index d0bbb735..00aac3dc 100644 --- a/back/src/Services/VariablesManager.ts +++ b/back/src/Services/VariablesManager.ts @@ -11,7 +11,6 @@ import { User } from "_Model/User"; import { variablesRepository } from "./Repository/VariablesRepository"; import { redisClient } from "./RedisClient"; import { VariableError } from "./VariableError"; -import log from "./Logger"; interface Variable { defaultValue?: string; @@ -100,7 +99,7 @@ export class VariablesManager { for (const object of layer.objects) { if (object.type === "variable") { if (object.template) { - log.warn( + console.warn( 'Warning, a variable object is using a Tiled "template". WorkAdventure does not support objects generated from Tiled templates.' ); continue; @@ -208,7 +207,7 @@ export class VariablesManager { if (variableObject !== undefined && variableObject.persist) { variablesRepository .saveVariable(this.roomUrl, name, value) - .catch((e) => log.error("Error while saving variable in Redis:", e)); + .catch((e) => console.error("Error while saving variable in Redis:", e)); } return readableBy; diff --git a/back/tsconfig.json b/back/tsconfig.json index cb55d5c1..e149d304 100644 --- a/back/tsconfig.json +++ b/back/tsconfig.json @@ -46,7 +46,7 @@ "paths": { "_Controller/*": ["src/Controller/*"], "_Model/*": ["src/Model/*"], - "_Enum/*": ["src/Enum/*"], + "_Enum/*": ["src/Enum/*"] }, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ // "typeRoots": [], /* List of folders to include type definitions from. */ diff --git a/back/yarn.lock b/back/yarn.lock index 9946289c..ff9cb180 100644 --- a/back/yarn.lock +++ b/back/yarn.lock @@ -23,15 +23,6 @@ chalk "^2.0.0" js-tokens "^4.0.0" -"@dabh/diagnostics@^2.0.2": - version "2.0.2" - resolved "https://registry.yarnpkg.com/@dabh/diagnostics/-/diagnostics-2.0.2.tgz#290d08f7b381b8f94607dc8f471a12c675f9db31" - integrity sha512-+A1YivoVDNNVCdfozHSR8v/jyuuLTMXwjWuxPFlFlUapXoGc+Gj9mDlTDDfrwl7rXCl2tNZ0kE8sIBO6YOn96Q== - dependencies: - colorspace "1.1.x" - enabled "2.0.x" - kuler "^2.0.0" - "@mrmlnc/readdir-enhanced@^2.2.1": version "2.2.1" resolved "https://registry.yarnpkg.com/@mrmlnc/readdir-enhanced/-/readdir-enhanced-2.2.1.tgz#524af240d1a360527b730475ecfa1344aa540dde" @@ -385,11 +376,6 @@ astral-regex@^2.0.0: resolved "https://registry.yarnpkg.com/astral-regex/-/astral-regex-2.0.0.tgz#483143c567aeed4785759c0865786dc77d7d2e31" integrity sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ== -async@^3.1.0: - version "3.2.2" - resolved "https://registry.yarnpkg.com/async/-/async-3.2.2.tgz#2eb7671034bb2194d45d30e31e24ec7e7f9670cd" - integrity sha512-H0E+qZaDEfx/FY4t7iLRv1W2fFI6+pyCeTw1uN20AQPiwqwM6ojPxHxdLv4z8hi2DtnW9BOckSspLucW7pIE5g== - atob@^2.1.2: version "2.1.2" resolved "https://registry.yarnpkg.com/atob/-/atob-2.1.2.tgz#6d9517eb9e030d2436666651e86bd9f6f13533c9" @@ -635,7 +621,7 @@ collection-visit@^1.0.0: map-visit "^1.0.0" object-visit "^1.0.0" -color-convert@^1.9.0, color-convert@^1.9.3: +color-convert@^1.9.0: version "1.9.3" resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" integrity sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg== @@ -654,45 +640,16 @@ color-name@1.1.3: resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" integrity sha1-p9BVi9icQveV3UIyj3QIMcpTvCU= -color-name@^1.0.0, color-name@~1.1.4: +color-name@~1.1.4: version "1.1.4" resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== -color-string@^1.6.0: - version "1.6.0" - resolved "https://registry.yarnpkg.com/color-string/-/color-string-1.6.0.tgz#c3915f61fe267672cb7e1e064c9d692219f6c312" - integrity sha512-c/hGS+kRWJutUBEngKKmk4iH3sD59MBkoxVapS/0wgpCz2u7XsNloxknyvBhzwEs1IbV36D9PwqLPJ2DTu3vMA== - dependencies: - color-name "^1.0.0" - simple-swizzle "^0.2.2" - -color@^3.1.3: - version "3.2.1" - resolved "https://registry.yarnpkg.com/color/-/color-3.2.1.tgz#3544dc198caf4490c3ecc9a790b54fe9ff45e164" - integrity sha512-aBl7dZI9ENN6fUGC7mWpMTPNHmWUSNan9tuWN6ahh5ZLNk9baLJOnSMlrQkHcrfFgz2/RigjUVAjdx36VcemKA== - dependencies: - color-convert "^1.9.3" - color-string "^1.6.0" - colorette@^1.2.2: version "1.2.2" resolved "https://registry.yarnpkg.com/colorette/-/colorette-1.2.2.tgz#cbcc79d5e99caea2dbf10eb3a26fd8b3e6acfa94" integrity sha512-MKGMzyfeuutC/ZJ1cba9NqcNpfeqMUcYmyF1ZFY6/Cn7CNSAKx6a+s48sqLqyAiZuaP2TcqMhoo+dlwFnVxT9w== -colors@^1.2.1: - version "1.4.0" - resolved "https://registry.yarnpkg.com/colors/-/colors-1.4.0.tgz#c50491479d4c1bdaed2c9ced32cf7c7dc2360f78" - integrity sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA== - -colorspace@1.1.x: - version "1.1.4" - resolved "https://registry.yarnpkg.com/colorspace/-/colorspace-1.1.4.tgz#8d442d1186152f60453bf8070cd66eb364e59243" - integrity sha512-BgvKJiuVu1igBUF2kEjRCZXol6wiiGbY5ipL/oVPwm0BL9sIpMIzM8IK7vwuxIIzOXMV3Ey5w+vxhm0rR/TN8w== - dependencies: - color "^3.1.3" - text-hex "1.0.x" - colour@~0.7.1: version "0.7.1" resolved "https://registry.yarnpkg.com/colour/-/colour-0.7.1.tgz#9cb169917ec5d12c0736d3e8685746df1cadf778" @@ -907,11 +864,6 @@ emoji-regex@^8.0.0: resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== -enabled@2.0.x: - version "2.0.0" - resolved "https://registry.yarnpkg.com/enabled/-/enabled-2.0.0.tgz#f9dd92ec2d6f4bbc0d5d1e64e21d61cd4665e7c2" - integrity sha512-AKrN98kuwOzMIdAizXGI86UFBoo26CL21UM763y1h/GMSJ4/OHU9k2YlsmBpyScFo/wbLzWQJBMCW4+IO3/+OQ== - enquirer@^2.3.6: version "2.3.6" resolved "https://registry.yarnpkg.com/enquirer/-/enquirer-2.3.6.tgz#2a7fe5dd634a1e4125a975ec994ff5456dc3734d" @@ -1137,11 +1089,6 @@ fast-levenshtein@~2.0.6: resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917" integrity sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc= -fecha@^4.2.0: - version "4.2.1" - resolved "https://registry.yarnpkg.com/fecha/-/fecha-4.2.1.tgz#0a83ad8f86ef62a091e22bb5a039cd03d23eecce" - integrity sha512-MMMQ0ludy/nBs1/o0zVOiKTpG7qMbonKUzjJgQFEuvq6INZ1OraKPRAWkBq5vlKLOUMpmNYG1JoN3oDPUQ9m3Q== - figures@^3.0.0: version "3.2.0" resolved "https://registry.yarnpkg.com/figures/-/figures-3.2.0.tgz#625c18bd293c604dc4a8ddb2febf0c88341746af" @@ -1195,11 +1142,6 @@ flatted@^2.0.0: resolved "https://registry.yarnpkg.com/flatted/-/flatted-2.0.2.tgz#4575b21e2bcee7434aa9be662f4b7b5f9c2b5138" integrity sha512-r5wGx7YeOwNWNlCA0wQ86zKyDLMQr+/RB8xy74M4hTphfmjlijTSSXGuH8rnvKZnfT9i+75zmd8jcKdMR4O6jA== -fn.name@1.x.x: - version "1.1.0" - resolved "https://registry.yarnpkg.com/fn.name/-/fn.name-1.1.0.tgz#26cad8017967aea8731bc42961d04a3d5988accc" - integrity sha512-GRnmB5gPyJpAhTQdSZTSp9uaPSvl09KoYcMQtsB9rQoOmzs9dH6ffeccH+Z+cv6P68Hu5bC6JjRh4Ah/mHSNRw== - follow-redirects@^1.14.0: version "1.14.4" resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.4.tgz#838fdf48a8bbdd79e52ee51fb1c94e3ed98b9379" @@ -1465,7 +1407,7 @@ inflight@^1.0.4: once "^1.3.0" wrappy "1" -inherits@2, inherits@^2.0.3, inherits@~2.0.3: +inherits@2, inherits@~2.0.3: version "2.0.4" resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== @@ -1523,11 +1465,6 @@ is-arrayish@^0.2.1: resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d" integrity sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0= -is-arrayish@^0.3.1: - version "0.3.2" - resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.3.2.tgz#4574a2ae56f7ab206896fb431eaeed066fdf8f03" - integrity sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ== - is-binary-path@~2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-2.1.0.tgz#ea1f7f3b80f064236e83470f86c09c254fb45b09" @@ -1794,11 +1731,6 @@ kind-of@^6.0.0, kind-of@^6.0.2: resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.3.tgz#07c05034a6c349fa06e24fa35aa76db4580ce4dd" integrity sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw== -kuler@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/kuler/-/kuler-2.0.0.tgz#e2c570a3800388fb44407e851531c1d670b061b3" - integrity sha512-Xq9nH7KlWZmXAtodXDDRE7vs6DU1gTU8zYDHDiWLSip45Egwq3plLHzPn27NgvzL2r1LMPC1vdqh98sQxtqj4A== - lcid@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/lcid/-/lcid-1.0.0.tgz#308accafa0bc483a3867b4b6f2b9506251d1b835" @@ -1932,17 +1864,6 @@ log-update@^4.0.0: slice-ansi "^4.0.0" wrap-ansi "^6.2.0" -logform@^2.2.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/logform/-/logform-2.3.0.tgz#a3997a05985de2ebd325ae0d166dffc9c6fe6b57" - integrity sha512-graeoWUH2knKbGthMtuG1EfaSPMZFZBIrhuJHhkS5ZseFBrc7DupCzihOQAzsK/qIKPQaPJ/lFQFctILUY5ARQ== - dependencies: - colors "^1.2.1" - fecha "^4.2.0" - ms "^2.1.1" - safe-stable-stringify "^1.1.0" - triple-beam "^1.3.0" - long@~3: version "3.2.0" resolved "https://registry.yarnpkg.com/long/-/long-3.2.0.tgz#d821b7138ca1cb581c172990ef14db200b5c474b" @@ -2256,13 +2177,6 @@ once@^1.3.0: dependencies: wrappy "1" -one-time@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/one-time/-/one-time-1.0.0.tgz#e06bc174aed214ed58edede573b433bbf827cb45" - integrity sha512-5DXOiRKwuSEcQ/l0kGCF6Q3jcADFv5tSmRaJck/OqkVFcOzutB134KRSfF0xDrL39MNnqxbHBbUUcjZIhTgb2g== - dependencies: - fn.name "1.x.x" - onetime@^5.1.0, onetime@^5.1.2: version "5.1.2" resolved "https://registry.yarnpkg.com/onetime/-/onetime-5.1.2.tgz#d0e96ebb56b07476df1dd9c4806e5237985ca45e" @@ -2511,7 +2425,7 @@ read-pkg@^1.0.0: normalize-package-data "^2.3.2" path-type "^1.0.0" -readable-stream@^2.0.6, readable-stream@^2.3.7: +readable-stream@^2.0.6: version "2.3.7" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.7.tgz#1eca1cf711aef814c04f62252a36a62f6cb23b57" integrity sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw== @@ -2524,15 +2438,6 @@ readable-stream@^2.0.6, readable-stream@^2.3.7: string_decoder "~1.1.1" util-deprecate "~1.0.1" -readable-stream@^3.4.0: - version "3.6.0" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.6.0.tgz#337bbda3adc0706bd3e024426a286d4b4b2c9198" - integrity sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA== - dependencies: - inherits "^2.0.3" - string_decoder "^1.1.1" - util-deprecate "^1.0.1" - readdirp@~3.4.0: version "3.4.0" resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.4.0.tgz#9fdccdf9e9155805449221ac645e8303ab5b9ada" @@ -2673,7 +2578,7 @@ rxjs@^6.6.7: dependencies: tslib "^1.9.0" -safe-buffer@^5.0.1, safe-buffer@^5.1.2, safe-buffer@^5.2.1, safe-buffer@~5.2.0: +safe-buffer@^5.0.1, safe-buffer@^5.1.2, safe-buffer@^5.2.1: version "5.2.1" resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== @@ -2690,11 +2595,6 @@ safe-regex@^1.1.0: dependencies: ret "~0.1.10" -safe-stable-stringify@^1.1.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/safe-stable-stringify/-/safe-stable-stringify-1.1.1.tgz#c8a220ab525cd94e60ebf47ddc404d610dc5d84a" - integrity sha512-ERq4hUjKDbJfE4+XtZLFPCDi8Vb1JqaxAPTxWFLBx8XcAlf9Bda/ZJdVezs/NAfsMQScyIlUMx+Yeu7P7rx5jw== - "safer-buffer@>= 2.1.2 < 3": version "2.1.2" resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" @@ -2769,13 +2669,6 @@ signal-exit@^3.0.0, signal-exit@^3.0.2, signal-exit@^3.0.3: resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.3.tgz#a1410c2edd8f077b08b4e253c8eacfcaf057461c" integrity sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA== -simple-swizzle@^0.2.2: - version "0.2.2" - resolved "https://registry.yarnpkg.com/simple-swizzle/-/simple-swizzle-0.2.2.tgz#a4da6b635ffcccca33f70d17cb92592de95e557a" - integrity sha1-pNprY1/8zMoz9w0Xy5JZLeleVXo= - dependencies: - is-arrayish "^0.3.1" - slice-ansi@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-2.1.0.tgz#cacd7693461a637a5788d92a7dd4fba068e81636" @@ -2910,11 +2803,6 @@ sprintf-js@~1.0.2: resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw= -stack-trace@0.0.x: - version "0.0.10" - resolved "https://registry.yarnpkg.com/stack-trace/-/stack-trace-0.0.10.tgz#547c70b347e8d32b4e108ea1a2a159e5fdde19c0" - integrity sha1-VHxws0fo0ytOEI6hoqFZ5f3eGcA= - static-extend@^0.1.1: version "0.1.2" resolved "https://registry.yarnpkg.com/static-extend/-/static-extend-0.1.2.tgz#60809c39cbff55337226fd5e0b520f341f1fb5c6" @@ -2982,13 +2870,6 @@ string-width@^4.2.0: is-fullwidth-code-point "^3.0.0" strip-ansi "^6.0.0" -string_decoder@^1.1.1: - version "1.3.0" - resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.3.0.tgz#42f114594a46cf1a8e30b0a84f56c78c3edac21e" - integrity sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA== - dependencies: - safe-buffer "~5.2.0" - string_decoder@~1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.1.1.tgz#9cf1611ba62685d7030ae9e4ba34149c3af03fc8" @@ -3111,11 +2992,6 @@ tdigest@^0.1.1: dependencies: bintrees "1.0.1" -text-hex@1.0.x: - version "1.0.0" - resolved "https://registry.yarnpkg.com/text-hex/-/text-hex-1.0.0.tgz#69dc9c1b17446ee79a92bf5b884bb4b9127506f5" - integrity sha512-uuVGNWzgJ4yhRaNSiubPY7OjISw4sw4E5Uv0wbjp+OzcbmVU/rsT8ujgcXJhn9ypzsgr5vlzpPqP+MBBKcGvbg== - text-table@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" @@ -3175,11 +3051,6 @@ trim-newlines@^1.0.0: resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-1.0.0.tgz#5887966bb582a4503a41eb524f7d35011815a613" integrity sha1-WIeWa7WCpFA6QetST301ARgVphM= -triple-beam@^1.2.0, triple-beam@^1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/triple-beam/-/triple-beam-1.3.0.tgz#a595214c7298db8339eeeee083e4d10bd8cb8dd9" - integrity sha512-XrHUvV5HpdLmIj4uVMxHggLbFSZYIn7HEWsqePZcI50pco+MPqJ50wMGY794X7AOOhxOBAjbkqfAbEe/QMp2Lw== - ts-node-dev@^1.0.0-pre.44: version "1.0.0-pre.63" resolved "https://registry.yarnpkg.com/ts-node-dev/-/ts-node-dev-1.0.0-pre.63.tgz#0e69df26cef35a728362d93348f13caa2cb2c512" @@ -3296,7 +3167,7 @@ use@^3.1.0: resolved "https://registry.yarnpkg.com/use/-/use-3.1.1.tgz#d50c8cac79a19fbc20f2911f56eb973f4e10070f" integrity sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ== -util-deprecate@^1.0.1, util-deprecate@~1.0.1: +util-deprecate@~1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" integrity sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8= @@ -3353,29 +3224,6 @@ window-size@^0.1.4: resolved "https://registry.yarnpkg.com/window-size/-/window-size-0.1.4.tgz#f8e1aa1ee5a53ec5bf151ffa09742a6ad7697876" integrity sha1-+OGqHuWlPsW/FR/6CXQqatdpeHY= -winston-transport@^4.4.0: - version "4.4.0" - resolved "https://registry.yarnpkg.com/winston-transport/-/winston-transport-4.4.0.tgz#17af518daa690d5b2ecccaa7acf7b20ca7925e59" - integrity sha512-Lc7/p3GtqtqPBYYtS6KCN3c77/2QCev51DvcJKbkFPQNoj1sinkGwLGFDxkXY9J6p9+EPnYs+D90uwbnaiURTw== - dependencies: - readable-stream "^2.3.7" - triple-beam "^1.2.0" - -winston@^3.3.3: - version "3.3.3" - resolved "https://registry.yarnpkg.com/winston/-/winston-3.3.3.tgz#ae6172042cafb29786afa3d09c8ff833ab7c9170" - integrity sha512-oEXTISQnC8VlSAKf1KYSSd7J6IWuRPQqDdo8eoRNaYKLvwSb5+79Z3Yi1lrl6KDpU6/VWaxpakDAtb1oQ4n9aw== - dependencies: - "@dabh/diagnostics" "^2.0.2" - async "^3.1.0" - is-stream "^2.0.0" - logform "^2.2.0" - one-time "^1.0.0" - readable-stream "^3.4.0" - stack-trace "0.0.x" - triple-beam "^1.3.0" - winston-transport "^4.4.0" - word-wrap@~1.2.3: version "1.2.3" resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.3.tgz#610636f6b1f703891bd34771ccb17fb93b47079c" diff --git a/front/src/Administration/AnalyticsClient.ts b/front/src/Administration/AnalyticsClient.ts index fb2b604b..ee85e8f4 100644 --- a/front/src/Administration/AnalyticsClient.ts +++ b/front/src/Administration/AnalyticsClient.ts @@ -4,7 +4,7 @@ declare let window: any; class AnalyticsClient { // eslint-disable-next-line @typescript-eslint/no-explicit-any - private posthogPromise: Promise | undefined; + private posthogPromise: Promise|undefined; constructor() { if (POSTHOG_API_KEY && POSTHOG_URL) { @@ -18,64 +18,74 @@ class AnalyticsClient { } identifyUser(uuid: string, email: string | null) { - this.posthogPromise?.then((posthog) => { - posthog.identify(uuid, { uuid, email, wa: true }); - }); + this.posthogPromise + ?.then((posthog) => { + posthog.identify(uuid, { uuid, email, wa: true }); + }); } loggedWithSso() { - this.posthogPromise?.then((posthog) => { - posthog.capture("wa-logged-sso"); - }); + this.posthogPromise + ?.then((posthog) => { + posthog.capture("wa-logged-sso"); + }); } loggedWithToken() { - this.posthogPromise?.then((posthog) => { - posthog.capture("wa-logged-token"); - }); + this.posthogPromise + ?.then((posthog) => { + posthog.capture("wa-logged-token"); + }); } enteredRoom(roomId: string, roomGroup: string | null) { - this.posthogPromise?.then((posthog) => { - posthog.capture("$pageView", { roomId, roomGroup }); - posthog.capture("enteredRoom"); - }); + this.posthogPromise + ?.then((posthog) => { + posthog.capture("$pageView", { roomId, roomGroup }); + posthog.capture("enteredRoom"); + }); } openedMenu() { - this.posthogPromise?.then((posthog) => { - posthog.capture("wa-opened-menu"); - }); + this.posthogPromise + ?.then((posthog) => { + posthog.capture("wa-opened-menu"); + }); } launchEmote(emote: string) { - this.posthogPromise?.then((posthog) => { - posthog.capture("wa-emote-launch", { emote }); - }); + this.posthogPromise + ?.then((posthog) => { + posthog.capture("wa-emote-launch", { emote }); + }); } enteredJitsi(roomName: string, roomId: string) { - this.posthogPromise?.then((posthog) => { - posthog.capture("wa-entered-jitsi", { roomName, roomId }); - }); + this.posthogPromise + ?.then((posthog) => { + posthog.capture("wa-entered-jitsi", { roomName, roomId }); + }); } validationName() { - this.posthogPromise?.then((posthog) => { - posthog.capture("wa-name-validation"); - }); + this.posthogPromise + ?.then((posthog) => { + posthog.capture("wa-name-validation"); + }); } validationWoka(scene: string) { - this.posthogPromise?.then((posthog) => { - posthog.capture("wa-woka-validation", { scene }); - }); + this.posthogPromise + ?.then((posthog) => { + posthog.capture("wa-woka-validation", { scene }); + }); } validationVideo() { - this.posthogPromise?.then((posthog) => { - posthog.capture("wa-video-validation"); - }); + this.posthogPromise + ?.then((posthog) => { + posthog.capture("wa-video-validation"); + }); } } export const analyticsClient = new AnalyticsClient(); diff --git a/front/src/Api/IframeListener.ts b/front/src/Api/IframeListener.ts index f30ce80c..871ec3b9 100644 --- a/front/src/Api/IframeListener.ts +++ b/front/src/Api/IframeListener.ts @@ -49,7 +49,7 @@ class IframeListener { public readonly openTabStream = this._openTabStream.asObservable(); private readonly _loadPageStream: Subject = new Subject(); - public readonly loadPageStream = this._loadPageStream.asObservable(); + public readonly loadPageStream = this._loadPageStream.asObservable() private readonly _disablePlayerControlStream: Subject = new Subject(); public readonly disablePlayerControlStream = this._disablePlayerControlStream.asObservable(); diff --git a/front/src/Connexion/LocalUserStore.ts b/front/src/Connexion/LocalUserStore.ts index ac57c3c7..a95618ba 100644 --- a/front/src/Connexion/LocalUserStore.ts +++ b/front/src/Connexion/LocalUserStore.ts @@ -122,7 +122,7 @@ class LocalUserStore { setLastRoomUrl(roomUrl: string): void { localStorage.setItem(lastRoomUrl, roomUrl.toString()); - if ("caches" in window) { + if ('caches' in window) { caches.open(cacheAPIIndex).then((cache) => { const stringResponse = new Response(JSON.stringify({ roomUrl })); cache.put(`/${lastRoomUrl}`, stringResponse); @@ -135,7 +135,7 @@ class LocalUserStore { ); } getLastRoomUrlCacheApi(): Promise { - if (!("caches" in window)) { + if (!('caches' in window)) { return Promise.resolve(undefined); } return caches.open(cacheAPIIndex).then((cache) => { diff --git a/front/src/Phaser/Components/Loader.ts b/front/src/Phaser/Components/Loader.ts index e013e758..0534aa91 100644 --- a/front/src/Phaser/Components/Loader.ts +++ b/front/src/Phaser/Components/Loader.ts @@ -13,10 +13,11 @@ export class Loader { private progressContainer!: Phaser.GameObjects.Graphics; private progress!: Phaser.GameObjects.Graphics; private progressAmount: number = 0; - private logo: Phaser.GameObjects.Image | undefined; + private logo: Phaser.GameObjects.Image|undefined; private loadingText: Phaser.GameObjects.Text | null = null; - public constructor(private scene: Phaser.Scene) {} + public constructor(private scene: Phaser.Scene) { + } public addLoader(): void { // If there is nothing to load, do not display the loader. @@ -29,19 +30,11 @@ export class Loader { const promiseLoadLogoTexture = new Promise((res) => { if (this.scene.load.textureManager.exists(LogoNameIndex)) { return res( - (this.logo = this.scene.add.image( - this.scene.game.renderer.width / 2, - this.scene.game.renderer.height / 2 - 150, - LogoNameIndex - )) + this.logo = this.scene.add.image(this.scene.game.renderer.width / 2, this.scene.game.renderer.height / 2 - 150, LogoNameIndex) ); } else { //add loading if logo image is not ready - this.loadingText = this.scene.add.text( - this.scene.game.renderer.width / 2, - this.scene.game.renderer.height / 2 - 50, - TextName - ); + this.loadingText = this.scene.add.text(this.scene.game.renderer.width / 2, this.scene.game.renderer.height / 2 - 50, TextName); } this.scene.load.spritesheet(LogoNameIndex, LogoResource, LogoFrame); this.scene.load.once(`filecomplete-spritesheet-${LogoNameIndex}`, () => { @@ -49,11 +42,7 @@ export class Loader { this.loadingText.destroy(); } return res( - (this.logo = this.scene.add.image( - this.scene.game.renderer.width / 2, - this.scene.game.renderer.height / 2 - 150, - LogoNameIndex - )) + this.logo = this.scene.add.image(this.scene.game.renderer.width / 2, this.scene.game.renderer.height / 2 - 150, LogoNameIndex) ); }); }); @@ -83,6 +72,7 @@ export class Loader { }); } + public removeLoader(): void { if (this.scene.load.textureManager.exists(LogoNameIndex)) { this.scene.load.textureManager.remove(LogoNameIndex); diff --git a/front/src/Phaser/Login/SelectCharacterScene.ts b/front/src/Phaser/Login/SelectCharacterScene.ts index 64fa9791..d9861b20 100644 --- a/front/src/Phaser/Login/SelectCharacterScene.ts +++ b/front/src/Phaser/Login/SelectCharacterScene.ts @@ -4,7 +4,7 @@ import { EnableCameraSceneName } from "./EnableCameraScene"; import { CustomizeSceneName } from "./CustomizeScene"; import { localUserStore } from "../../Connexion/LocalUserStore"; import { loadAllDefaultModels } from "../Entity/PlayerTexturesLoadingManager"; -import { Loader } from "../Components/Loader"; +import { Loader} from "../Components/Loader"; import type { BodyResourceDescriptionInterface } from "../Entity/PlayerTextures"; import { AbstractCharacterScene } from "./AbstractCharacterScene"; import { areCharacterLayersValid } from "../../Connexion/LocalUser"; diff --git a/package.json b/package.json index ff6c2a33..038edf2c 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,5 @@ }, "scripts": { "prepare": "husky install" - }, - "dependencies": {} + } } diff --git a/pusher/package.json b/pusher/package.json index a51d51f4..dacbfd72 100644 --- a/pusher/package.json +++ b/pusher/package.json @@ -53,8 +53,7 @@ "prom-client": "^12.0.0", "query-string": "^6.13.3", "uWebSockets.js": "uNetworking/uWebSockets.js#v18.5.0", - "uuidv4": "^6.0.7", - "winston": "^3.3.3" + "uuidv4": "^6.0.7" }, "devDependencies": { "@types/busboy": "^0.2.3", diff --git a/pusher/server.ts b/pusher/server.ts index e567eb14..40810d98 100644 --- a/pusher/server.ts +++ b/pusher/server.ts @@ -1,6 +1,4 @@ // lib/server.ts import App from "./src/App"; import { PUSHER_HTTP_PORT } from "./src/Enum/EnvironmentVariable"; -import log from "./src/Services/Logger"; - -App.listen(PUSHER_HTTP_PORT, () => log.info(`WorkAdventure starting on port ${PUSHER_HTTP_PORT}!`)); +App.listen(PUSHER_HTTP_PORT, () => console.log(`WorkAdventure starting on port ${PUSHER_HTTP_PORT}!`)) diff --git a/pusher/src/Controller/AdminController.ts b/pusher/src/Controller/AdminController.ts index 4f7166f7..ec1bd067 100644 --- a/pusher/src/Controller/AdminController.ts +++ b/pusher/src/Controller/AdminController.ts @@ -7,7 +7,6 @@ import { WorldFullWarningToRoomMessage, RefreshRoomPromptMessage, } from "../Messages/generated/messages_pb"; -import log from "../Services/Logger"; export class AdminController extends BaseController { constructor(private App: TemplatedApp) { @@ -26,14 +25,14 @@ export class AdminController extends BaseController { // eslint-disable-next-line @typescript-eslint/no-misused-promises this.App.post("/room/refresh", async (res: HttpResponse, req: HttpRequest) => { res.onAborted(() => { - log.warn("/message request was aborted"); + console.warn("/message request was aborted"); }); const token = req.getHeader("admin-token"); const body = await res.json(); if (token !== ADMIN_API_TOKEN) { - log.error("Admin access refused for token: " + token); + console.error("Admin access refused for token: " + token); res.writeStatus("401 Unauthorized").end("Incorrect token"); return; } @@ -73,14 +72,14 @@ export class AdminController extends BaseController { // eslint-disable-next-line @typescript-eslint/no-misused-promises this.App.post("/message", async (res: HttpResponse, req: HttpRequest) => { res.onAborted(() => { - log.warn("/message request was aborted"); + console.warn("/message request was aborted"); }); const token = req.getHeader("admin-token"); const body = await res.json(); if (token !== ADMIN_API_TOKEN) { - log.error("Admin access refused for token: " + token); + console.error("Admin access refused for token: " + token); res.writeStatus("401 Unauthorized").end("Incorrect token"); return; } diff --git a/pusher/src/Controller/AuthenticateController.ts b/pusher/src/Controller/AuthenticateController.ts index 51ee9c2d..fb428141 100644 --- a/pusher/src/Controller/AuthenticateController.ts +++ b/pusher/src/Controller/AuthenticateController.ts @@ -6,7 +6,6 @@ import { AuthTokenData, jwtTokenManager } from "../Services/JWTTokenManager"; import { parse } from "query-string"; import { openIDClient } from "../Services/OpenIDClient"; import { DISABLE_ANONYMOUS } from "../Enum/EnvironmentVariable"; -import log from "../Services/Logger"; export interface TokenInterface { userUuid: string; @@ -26,7 +25,7 @@ export class AuthenticateController extends BaseController { //eslint-disable-next-line @typescript-eslint/no-misused-promises this.App.get("/login-screen", async (res: HttpResponse, req: HttpRequest) => { res.onAborted(() => { - log.warn("/message request was aborted"); + console.warn("/message request was aborted"); }); try { @@ -45,7 +44,7 @@ export class AuthenticateController extends BaseController { res.writeHeader("Location", loginUri); return res.end(); } catch (e) { - log.error("openIDLogin => e", e); + console.error("openIDLogin => e", e); return this.errorToResponse(e, res); } }); @@ -55,7 +54,7 @@ export class AuthenticateController extends BaseController { //eslint-disable-next-line @typescript-eslint/no-misused-promises this.App.get("/login-callback", async (res: HttpResponse, req: HttpRequest) => { res.onAborted(() => { - log.warn("/message request was aborted"); + console.warn("/message request was aborted"); }); const IPAddress = req.getHeader("x-forwarded-for"); const { code, nonce, token, playUri } = parse(req.getQuery()); @@ -89,7 +88,7 @@ export class AuthenticateController extends BaseController { this.addCorsHeaders(res); return res.end(JSON.stringify({ ...resCheckTokenAuth, ...resUserData, authToken: token })); } catch (err) { - log.info("User was not connected", err); + console.info("User was not connected", err); } } @@ -109,7 +108,7 @@ export class AuthenticateController extends BaseController { this.addCorsHeaders(res); return res.end(JSON.stringify({ ...data, authToken })); } catch (e) { - log.error("openIDCallback => ERROR", e); + console.error("openIDCallback => ERROR", e); return this.errorToResponse(e, res); } }); @@ -117,7 +116,7 @@ export class AuthenticateController extends BaseController { // eslint-disable-next-line @typescript-eslint/no-misused-promises this.App.get("/logout-callback", async (res: HttpResponse, req: HttpRequest) => { res.onAborted(() => { - log.warn("/message request was aborted"); + console.warn("/message request was aborted"); }); const { token } = parse(req.getQuery()); @@ -129,7 +128,7 @@ export class AuthenticateController extends BaseController { } await openIDClient.logoutUser(authTokenData.accessToken); } catch (error) { - log.error("openIDCallback => logout-callback", error); + console.error("openIDCallback => logout-callback", error); } finally { res.writeStatus("200"); this.addCorsHeaders(res); @@ -150,7 +149,7 @@ export class AuthenticateController extends BaseController { this.App.post("/register", (res: HttpResponse, req: HttpRequest) => { (async () => { res.onAborted(() => { - log.warn("Login request was aborted"); + console.warn("Login request was aborted"); }); const param = await res.json(); @@ -181,7 +180,7 @@ export class AuthenticateController extends BaseController { }) ); } catch (e) { - log.error("register => ERROR", e); + console.error("register => ERROR", e); this.errorToResponse(e, res); } })(); @@ -197,7 +196,7 @@ export class AuthenticateController extends BaseController { this.App.post("/anonymLogin", (res: HttpResponse, req: HttpRequest) => { res.onAborted(() => { - log.warn("Login request was aborted"); + console.warn("Login request was aborted"); }); if (DISABLE_ANONYMOUS) { @@ -224,7 +223,7 @@ export class AuthenticateController extends BaseController { // eslint-disable-next-line @typescript-eslint/no-misused-promises this.App.get("/profile-callback", async (res: HttpResponse, req: HttpRequest) => { res.onAborted(() => { - log.warn("/message request was aborted"); + console.warn("/message request was aborted"); }); const { token } = parse(req.getQuery()); try { @@ -248,7 +247,7 @@ export class AuthenticateController extends BaseController { } } } catch (error) { - log.error("profileCallback => ERROR", error); + console.error("profileCallback => ERROR", error); this.errorToResponse(error, res); } }); diff --git a/pusher/src/Controller/BaseController.ts b/pusher/src/Controller/BaseController.ts index eb41c83e..f5465e1b 100644 --- a/pusher/src/Controller/BaseController.ts +++ b/pusher/src/Controller/BaseController.ts @@ -1,6 +1,5 @@ import { HttpResponse } from "uWebSockets.js"; import { FRONT_URL } from "../Enum/EnvironmentVariable"; -import log from "../Services/Logger"; export class BaseController { protected addCorsHeaders(res: HttpResponse): void { @@ -21,12 +20,12 @@ export class BaseController { } else { url = ""; } - log.error("ERROR: " + e.message + url); + console.error("ERROR: " + e.message + url); } else if (typeof e === "string") { - log.error(e); + console.error(e); } if (e.stack) { - log.error(e.stack); + console.error(e.stack); } if (e.response) { res.writeStatus(e.response.status + " " + e.response.statusText); diff --git a/pusher/src/Controller/IoSocketController.ts b/pusher/src/Controller/IoSocketController.ts index 4d3c7f25..35fd08d5 100644 --- a/pusher/src/Controller/IoSocketController.ts +++ b/pusher/src/Controller/IoSocketController.ts @@ -30,7 +30,6 @@ import { ADMIN_SOCKETS_TOKEN, ADMIN_API_URL, DISABLE_ANONYMOUS, SOCKET_IDLE_TIME import { Zone } from "_Model/Zone"; import { ExAdminSocketInterface } from "_Model/Websocket/ExAdminSocketInterface"; import { CharacterTexture } from "../Services/AdminApi/CharacterTexture"; -import log from "../Services/Logger"; export class IoSocketController { private nextUserId: number = 1; @@ -53,13 +52,13 @@ export class IoSocketController { const data = jwtTokenManager.verifyAdminSocketToken(token as string); authorizedRoomIds = data.authorizedRoomIds; } catch (e) { - log.info("Admin access refused for token: " + token); + console.error("Admin access refused for token: " + token); res.writeStatus("401 Unauthorized").end("Incorrect token"); return; } const roomId = query.roomId; if (typeof roomId !== "string" || !authorizedRoomIds.includes(roomId)) { - log.error("Invalid room id"); + console.error("Invalid room id"); res.writeStatus("403 Bad Request").end("Invalid room id"); return; } @@ -67,7 +66,7 @@ export class IoSocketController { res.upgrade({ roomId }, websocketKey, websocketProtocol, websocketExtensions, context); }, open: (ws) => { - log.info("Admin socket connect for room: " + ws.roomId); + console.log("Admin socket connect for room: " + ws.roomId); ws.disconnecting = false; socketManager.handleAdminRoom(ws as ExAdminSocketInterface, ws.roomId as string); @@ -98,7 +97,7 @@ export class IoSocketController { } } } catch (err) { - log.error(err); + console.error(err); } }, close: (ws, code, message) => { @@ -107,8 +106,8 @@ export class IoSocketController { Client.disconnecting = true; socketManager.leaveAdminRoom(Client); } catch (e) { - log.error('An error occurred on admin "disconnect"'); - log.error(e); + console.error('An error occurred on admin "disconnect"'); + console.error(e); } }, }); @@ -206,7 +205,7 @@ export class IoSocketController { if (err?.response?.status == 404) { // If we get an HTTP 404, the token is invalid. Let's perform an anonymous login! - log.warn( + console.warn( 'Cannot find user with email "' + (userIdentifier || "anonymous") + '". Performing an anonymous login instead.' @@ -246,13 +245,13 @@ export class IoSocketController { throw new Error("Use the login URL to connect"); } } catch (e) { - log.info( + console.log( "access not granted for user " + (userIdentifier || "anonymous") + " and room " + roomId ); - log.error(e); + console.error(e); throw new Error("User cannot access this world"); } } @@ -262,7 +261,7 @@ export class IoSocketController { SocketManager.mergeCharacterLayersAndCustomTextures(characterLayers, memberTextures); if (upgradeAborted.aborted) { - log.info("Ouch! Client disconnected before we could upgrade it!"); + console.log("Ouch! Client disconnected before we could upgrade it!"); /* You must not upgrade now */ return; } @@ -403,7 +402,7 @@ export class IoSocketController { //let ok = ws.send(message, isBinary); }, drain: (ws) => { - log.info("WebSocket backpressure: " + ws.getBufferedAmount()); + console.log("WebSocket backpressure: " + ws.getBufferedAmount()); }, close: (ws, code, message) => { const Client = ws as ExSocketInterface; @@ -412,8 +411,8 @@ export class IoSocketController { //leave room socketManager.leaveRoom(Client); } catch (e) { - log.error('An error occurred on "disconnect"'); - log.error(e); + console.error('An error occurred on "disconnect"'); + console.error(e); } }, }); diff --git a/pusher/src/Controller/MapController.ts b/pusher/src/Controller/MapController.ts index ac8c8806..7f76ff9e 100644 --- a/pusher/src/Controller/MapController.ts +++ b/pusher/src/Controller/MapController.ts @@ -8,7 +8,6 @@ import { isMapDetailsData, MapDetailsData } from "../Services/AdminApi/MapDetail import { socketManager } from "../Services/SocketManager"; import { AuthTokenData, jwtTokenManager } from "../Services/JWTTokenManager"; import { v4 } from "uuid"; -import log from "../Services/Logger"; export class MapController extends BaseController { constructor(private App: TemplatedApp) { @@ -26,13 +25,13 @@ export class MapController extends BaseController { this.App.get("/map", (res: HttpResponse, req: HttpRequest) => { res.onAborted(() => { - log.warn("/map request was aborted"); + console.warn("/map request was aborted"); }); const query = parse(req.getQuery()); if (typeof query.playUri !== "string") { - log.error("Expected playUri parameter in /map endpoint"); + console.error("Expected playUri parameter in /map endpoint"); res.writeStatus("400 Bad request"); this.addCorsHeaders(res); res.end("Expected playUri parameter"); @@ -84,7 +83,7 @@ export class MapController extends BaseController { // Decode token, in this case we don't need to create new token. authTokenData = jwtTokenManager.verifyJWTToken(query.authToken as string, true); userId = authTokenData.identifier; - log.info("JWT expire, but decoded", userId); + console.info("JWT expire, but decoded", userId); } catch (e) { // The token was not good, redirect user on login page res.writeStatus("500"); diff --git a/pusher/src/Model/PositionDispatcher.ts b/pusher/src/Model/PositionDispatcher.ts index ec95eded..f868cd2c 100644 --- a/pusher/src/Model/PositionDispatcher.ts +++ b/pusher/src/Model/PositionDispatcher.ts @@ -11,7 +11,6 @@ import { Zone, ZoneEventListener } from "./Zone"; import { ViewportInterface } from "_Model/Websocket/ViewportMessage"; import { ExSocketInterface } from "_Model/Websocket/ExSocketInterface"; -import log from "../Services/Logger"; //import Debug from "debug"; //const debug = Debug('positiondispatcher'); @@ -45,7 +44,7 @@ export class PositionDispatcher { */ public setViewport(socket: ExSocketInterface, viewport: ViewportInterface): void { if (viewport.left > viewport.right || viewport.top > viewport.bottom) { - log.warn("Invalid viewport received: ", viewport); + console.warn("Invalid viewport received: ", viewport); return; } diff --git a/pusher/src/Model/Zone.ts b/pusher/src/Model/Zone.ts index 07255da7..d5a6058f 100644 --- a/pusher/src/Model/Zone.ts +++ b/pusher/src/Model/Zone.ts @@ -20,7 +20,6 @@ import { import { ClientReadableStream } from "grpc"; import { PositionDispatcher } from "_Model/PositionDispatcher"; import Debug from "debug"; -import log from "../Services/Logger"; const debug = Debug("zone"); @@ -210,7 +209,7 @@ export class Zone { const userDescriptor = this.users.get(userId); if (userDescriptor === undefined) { - log.error('Unexpected move message received for user "' + userId + '"'); + console.error('Unexpected move message received for user "' + userId + '"'); return; } diff --git a/pusher/src/Server/server/formdata.ts b/pusher/src/Server/server/formdata.ts index 0c9992d8..66e51db4 100644 --- a/pusher/src/Server/server/formdata.ts +++ b/pusher/src/Server/server/formdata.ts @@ -2,7 +2,6 @@ import { createWriteStream } from "fs"; import { join, dirname } from "path"; import Busboy from "busboy"; import mkdirp from "mkdirp"; -import log from "../../Services/Logger"; function formData( contType: string, @@ -20,7 +19,7 @@ function formData( filename?: (oldName: string) => string; } = {} ) { - log.info("Enter form data"); + console.log("Enter form data"); options.headers = { "content-type": contType, }; diff --git a/pusher/src/Services/CpuTracker.ts b/pusher/src/Services/CpuTracker.ts index 4ff48eb6..3d06ca70 100644 --- a/pusher/src/Services/CpuTracker.ts +++ b/pusher/src/Services/CpuTracker.ts @@ -1,5 +1,4 @@ import { CPU_OVERHEAT_THRESHOLD } from "../Enum/EnvironmentVariable"; -import log from "./Logger"; function secNSec2ms(secNSec: Array | number) { if (Array.isArray(secNSec)) { @@ -29,16 +28,16 @@ class CpuTracker { if (!this.overHeating && this.cpuPercent > CPU_OVERHEAT_THRESHOLD) { this.overHeating = true; - log.warn('CPU high threshold alert. Going in "overheat" mode'); + console.warn('CPU high threshold alert. Going in "overheat" mode'); } else if (this.overHeating && this.cpuPercent <= CPU_OVERHEAT_THRESHOLD) { this.overHeating = false; - log.info('CPU is back to normal. Canceling "overheat" mode'); + console.log('CPU is back to normal. Canceling "overheat" mode'); } - /*log.info('elapsed time ms: ', elapTimeMS) - log.info('elapsed user ms: ', elapUserMS) - log.info('elapsed system ms:', elapSystMS) - log.info('cpu percent: ', this.cpuPercent)*/ + /*console.log('elapsed time ms: ', elapTimeMS) + console.log('elapsed user ms: ', elapUserMS) + console.log('elapsed system ms:', elapSystMS) + console.log('cpu percent: ', this.cpuPercent)*/ }, 100); } diff --git a/pusher/src/Services/IoSocketHelpers.ts b/pusher/src/Services/IoSocketHelpers.ts index efe72e20..2da7c430 100644 --- a/pusher/src/Services/IoSocketHelpers.ts +++ b/pusher/src/Services/IoSocketHelpers.ts @@ -1,7 +1,6 @@ import { ExSocketInterface } from "_Model/Websocket/ExSocketInterface"; import { BatchMessage, ErrorMessage, ServerToClientMessage, SubMessage } from "../Messages/generated/messages_pb"; import { WebSocket } from "uWebSockets.js"; -import log from "./Logger"; export function emitInBatch(socket: ExSocketInterface, payload: SubMessage): void { socket.batchedMessages.addPayload(payload); @@ -32,5 +31,5 @@ export function emitError(Client: WebSocket, message: string): void { if (!Client.disconnecting) { Client.send(serverToClientMessage.serializeBinary().buffer, true); } - log.warn(message); + console.warn(message); } diff --git a/pusher/src/Services/Logger.ts b/pusher/src/Services/Logger.ts deleted file mode 100644 index e19f60d1..00000000 --- a/pusher/src/Services/Logger.ts +++ /dev/null @@ -1,16 +0,0 @@ -import * as winston from "winston"; - -const logger = winston.createLogger({ - transports: [ - new winston.transports.Console({ - format: winston.format.combine( - winston.format.colorize(), - winston.format.timestamp(), - winston.format.align(), - winston.format.printf((info) => `${info.timestamp} ${info.level}: ${info.message}`) - ), - }), - ], -}); - -export default logger; diff --git a/pusher/src/Services/SocketManager.ts b/pusher/src/Services/SocketManager.ts index d3458b3a..1761f1bd 100644 --- a/pusher/src/Services/SocketManager.ts +++ b/pusher/src/Services/SocketManager.ts @@ -49,7 +49,6 @@ import { ExAdminSocketInterface } from "_Model/Websocket/ExAdminSocketInterface" import { WebSocket } from "uWebSockets.js"; import { isRoomRedirect } from "./AdminApi/RoomRedirect"; import { CharacterTexture } from "./AdminApi/CharacterTexture"; -import log from "./Logger"; const debug = Debug("socket"); @@ -116,15 +115,15 @@ export class SocketManager implements ZoneEventListener { } }) .on("end", () => { - log.warn("Admin connection lost to back server"); + console.warn("Admin connection lost to back server"); // Let's close the front connection if the back connection is closed. This way, we can retry connecting from the start. if (!client.disconnecting) { this.closeWebsocketConnection(client, 1011, "Admin Connection lost to back server"); } - log.info("A user left"); + console.log("A user left"); }) .on("error", (err: Error) => { - log.error("Error in connection to back server:", err); + console.error("Error in connection to back server:", err); if (!client.disconnecting) { this.closeWebsocketConnection(client, 1011, "Error while connecting to back server"); } @@ -167,7 +166,7 @@ export class SocketManager implements ZoneEventListener { joinRoomMessage.addCharacterlayer(characterLayerMessage); } - log.info("Calling joinRoom '" + client.roomId + "' for client " + client.userUuid); + console.log("Calling joinRoom"); const apiClient = await apiClientRepository.getClient(client.roomId); const streamToPusher = apiClient.joinRoom(); clientEventsEmitter.emitClientJoin(client.userUuid, client.roomId); @@ -195,25 +194,17 @@ export class SocketManager implements ZoneEventListener { } }) .on("end", () => { + console.warn("Connection lost to back server"); // Let's close the front connection if the back connection is closed. This way, we can retry connecting from the start. if (!client.disconnecting) { this.closeWebsocketConnection(client, 1011, "Connection lost to back server"); } - log.info( - "Closed connection for user '" + - client.userUuid + - "' to back server " + - apiClient.getChannel().getTarget() - ); + console.log("A user left"); }) .on("error", (err: Error) => { - log.error("Error in connection to back server '" + apiClient.getChannel().getTarget() + "':", err); + console.error("Error in connection to back server:", err); if (!client.disconnecting) { - this.closeWebsocketConnection( - client, - 1011, - "Error while connecting to back server '" + apiClient.getChannel().getTarget() + "'" - ); + this.closeWebsocketConnection(client, 1011, "Error while connecting to back server"); } }); @@ -224,8 +215,8 @@ export class SocketManager implements ZoneEventListener { const pusherRoom = await this.getOrCreateRoom(client.roomId); pusherRoom.join(client); } catch (e) { - log.error('An error occurred on "join_room" event'); - log.error(e); + console.error('An error occurred on "join_room" event'); + console.error(e); } } @@ -242,13 +233,13 @@ export class SocketManager implements ZoneEventListener { const room = this.rooms.get(client.roomId); if (!room) { - log.error("In SET_VIEWPORT, could not find world with id '", client.roomId, "'"); + console.error("In SET_VIEWPORT, could not find world with id '", client.roomId, "'"); return; } room.setViewport(client, client.viewport); } catch (e) { - log.error('An error occurred on "SET_VIEWPORT" event'); - log.error(e); + console.error('An error occurred on "SET_VIEWPORT" event'); + console.error(e); } } @@ -319,8 +310,8 @@ export class SocketManager implements ZoneEventListener { client.roomId ); } catch (e) { - log.error('An error occurred on "handleReportMessage"'); - log.error(e); + console.error('An error occurred on "handleReportMessage"'); + console.error(e); } } @@ -355,14 +346,14 @@ export class SocketManager implements ZoneEventListener { debug("Room %s is empty. Deleting.", socket.roomId); } } else { - log.error("Could not find the GameRoom the user is leaving!"); + console.error("Could not find the GameRoom the user is leaving!"); } //user leave previous room //Client.leave(Client.roomId); } finally { //delete Client.roomId; clientEventsEmitter.emitClientLeave(socket.userUuid, socket.roomId); - log.info("User '" + socket.userUuid + "' left"); + console.log("A user left"); } } } finally { @@ -444,7 +435,7 @@ export class SocketManager implements ZoneEventListener { client.send(serverToClientMessage.serializeBinary().buffer, true); } catch (e) { - log.error("An error occurred while generating the Jitsi JWT token: ", e); + console.error("An error occurred while generating the Jitsi JWT token: ", e); } } @@ -468,7 +459,7 @@ export class SocketManager implements ZoneEventListener { backAdminMessage.setType(type); backConnection.sendAdminMessage(backAdminMessage, (error) => { if (error !== null) { - log.error("Error while sending admin message", error); + console.error("Error while sending admin message", error); } }); } @@ -493,7 +484,7 @@ export class SocketManager implements ZoneEventListener { banMessage.setType(type); backConnection.ban(banMessage, (error) => { if (error !== null) { - log.error("Error while sending admin message", error); + console.error("Error while sending admin message", error); } }); } diff --git a/pusher/yarn.lock b/pusher/yarn.lock index 4461a86d..820575aa 100644 --- a/pusher/yarn.lock +++ b/pusher/yarn.lock @@ -23,15 +23,6 @@ chalk "^2.0.0" js-tokens "^4.0.0" -"@dabh/diagnostics@^2.0.2": - version "2.0.2" - resolved "https://registry.yarnpkg.com/@dabh/diagnostics/-/diagnostics-2.0.2.tgz#290d08f7b381b8f94607dc8f471a12c675f9db31" - integrity sha512-+A1YivoVDNNVCdfozHSR8v/jyuuLTMXwjWuxPFlFlUapXoGc+Gj9mDlTDDfrwl7rXCl2tNZ0kE8sIBO6YOn96Q== - dependencies: - colorspace "1.1.x" - enabled "2.0.x" - kuler "^2.0.0" - "@mapbox/node-pre-gyp@^1.0.4": version "1.0.5" resolved "https://registry.yarnpkg.com/@mapbox/node-pre-gyp/-/node-pre-gyp-1.0.5.tgz#2a0b32fcb416fb3f2250fd24cb2a81421a4f5950" @@ -376,11 +367,6 @@ astral-regex@^2.0.0: resolved "https://registry.yarnpkg.com/astral-regex/-/astral-regex-2.0.0.tgz#483143c567aeed4785759c0865786dc77d7d2e31" integrity sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ== -async@^3.1.0: - version "3.2.2" - resolved "https://registry.yarnpkg.com/async/-/async-3.2.2.tgz#2eb7671034bb2194d45d30e31e24ec7e7f9670cd" - integrity sha512-H0E+qZaDEfx/FY4t7iLRv1W2fFI6+pyCeTw1uN20AQPiwqwM6ojPxHxdLv4z8hi2DtnW9BOckSspLucW7pIE5g== - axios@^0.21.2: version "0.21.2" resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.2.tgz#21297d5084b2aeeb422f5d38e7be4fbb82239017" @@ -563,7 +549,7 @@ code-point-at@^1.0.0: resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77" integrity sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c= -color-convert@^1.9.0, color-convert@^1.9.3: +color-convert@^1.9.0: version "1.9.3" resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" integrity sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg== @@ -582,45 +568,16 @@ color-name@1.1.3: resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" integrity sha1-p9BVi9icQveV3UIyj3QIMcpTvCU= -color-name@^1.0.0, color-name@~1.1.4: +color-name@~1.1.4: version "1.1.4" resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== -color-string@^1.6.0: - version "1.6.0" - resolved "https://registry.yarnpkg.com/color-string/-/color-string-1.6.0.tgz#c3915f61fe267672cb7e1e064c9d692219f6c312" - integrity sha512-c/hGS+kRWJutUBEngKKmk4iH3sD59MBkoxVapS/0wgpCz2u7XsNloxknyvBhzwEs1IbV36D9PwqLPJ2DTu3vMA== - dependencies: - color-name "^1.0.0" - simple-swizzle "^0.2.2" - -color@^3.1.3: - version "3.2.1" - resolved "https://registry.yarnpkg.com/color/-/color-3.2.1.tgz#3544dc198caf4490c3ecc9a790b54fe9ff45e164" - integrity sha512-aBl7dZI9ENN6fUGC7mWpMTPNHmWUSNan9tuWN6ahh5ZLNk9baLJOnSMlrQkHcrfFgz2/RigjUVAjdx36VcemKA== - dependencies: - color-convert "^1.9.3" - color-string "^1.6.0" - colorette@^1.2.2: version "1.2.2" resolved "https://registry.yarnpkg.com/colorette/-/colorette-1.2.2.tgz#cbcc79d5e99caea2dbf10eb3a26fd8b3e6acfa94" integrity sha512-MKGMzyfeuutC/ZJ1cba9NqcNpfeqMUcYmyF1ZFY6/Cn7CNSAKx6a+s48sqLqyAiZuaP2TcqMhoo+dlwFnVxT9w== -colors@^1.2.1: - version "1.4.0" - resolved "https://registry.yarnpkg.com/colors/-/colors-1.4.0.tgz#c50491479d4c1bdaed2c9ced32cf7c7dc2360f78" - integrity sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA== - -colorspace@1.1.x: - version "1.1.4" - resolved "https://registry.yarnpkg.com/colorspace/-/colorspace-1.1.4.tgz#8d442d1186152f60453bf8070cd66eb364e59243" - integrity sha512-BgvKJiuVu1igBUF2kEjRCZXol6wiiGbY5ipL/oVPwm0BL9sIpMIzM8IK7vwuxIIzOXMV3Ey5w+vxhm0rR/TN8w== - dependencies: - color "^3.1.3" - text-hex "1.0.x" - colour@~0.7.1: version "0.7.1" resolved "https://registry.yarnpkg.com/colour/-/colour-0.7.1.tgz#9cb169917ec5d12c0736d3e8685746df1cadf778" @@ -774,11 +731,6 @@ emoji-regex@^8.0.0: resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== -enabled@2.0.x: - version "2.0.0" - resolved "https://registry.yarnpkg.com/enabled/-/enabled-2.0.0.tgz#f9dd92ec2d6f4bbc0d5d1e64e21d61cd4665e7c2" - integrity sha512-AKrN98kuwOzMIdAizXGI86UFBoo26CL21UM763y1h/GMSJ4/OHU9k2YlsmBpyScFo/wbLzWQJBMCW4+IO3/+OQ== - end-of-stream@^1.1.0: version "1.4.4" resolved "https://registry.yarnpkg.com/end-of-stream/-/end-of-stream-1.4.4.tgz#5ae64a5f45057baf3626ec14da0ca5e4b2431eb0" @@ -957,11 +909,6 @@ fast-levenshtein@~2.0.6: resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917" integrity sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc= -fecha@^4.2.0: - version "4.2.1" - resolved "https://registry.yarnpkg.com/fecha/-/fecha-4.2.1.tgz#0a83ad8f86ef62a091e22bb5a039cd03d23eecce" - integrity sha512-MMMQ0ludy/nBs1/o0zVOiKTpG7qMbonKUzjJgQFEuvq6INZ1OraKPRAWkBq5vlKLOUMpmNYG1JoN3oDPUQ9m3Q== - figures@^3.0.0: version "3.2.0" resolved "https://registry.yarnpkg.com/figures/-/figures-3.2.0.tgz#625c18bd293c604dc4a8ddb2febf0c88341746af" @@ -1002,11 +949,6 @@ flatted@^2.0.0: resolved "https://registry.yarnpkg.com/flatted/-/flatted-2.0.2.tgz#4575b21e2bcee7434aa9be662f4b7b5f9c2b5138" integrity sha512-r5wGx7YeOwNWNlCA0wQ86zKyDLMQr+/RB8xy74M4hTphfmjlijTSSXGuH8rnvKZnfT9i+75zmd8jcKdMR4O6jA== -fn.name@1.x.x: - version "1.1.0" - resolved "https://registry.yarnpkg.com/fn.name/-/fn.name-1.1.0.tgz#26cad8017967aea8731bc42961d04a3d5988accc" - integrity sha512-GRnmB5gPyJpAhTQdSZTSp9uaPSvl09KoYcMQtsB9rQoOmzs9dH6ffeccH+Z+cv6P68Hu5bC6JjRh4Ah/mHSNRw== - follow-redirects@^1.14.0: version "1.14.4" resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.4.tgz#838fdf48a8bbdd79e52ee51fb1c94e3ed98b9379" @@ -1226,7 +1168,7 @@ inflight@^1.0.4: once "^1.3.0" wrappy "1" -inherits@2, inherits@^2.0.3, inherits@~2.0.3: +inherits@2, inherits@~2.0.3: version "2.0.4" resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== @@ -1260,11 +1202,6 @@ is-arrayish@^0.2.1: resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d" integrity sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0= -is-arrayish@^0.3.1: - version "0.3.2" - resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.3.2.tgz#4574a2ae56f7ab206896fb431eaeed066fdf8f03" - integrity sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ== - is-binary-path@~2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-2.1.0.tgz#ea1f7f3b80f064236e83470f86c09c254fb45b09" @@ -1436,11 +1373,6 @@ keyv@^4.0.0: dependencies: json-buffer "3.0.1" -kuler@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/kuler/-/kuler-2.0.0.tgz#e2c570a3800388fb44407e851531c1d670b061b3" - integrity sha512-Xq9nH7KlWZmXAtodXDDRE7vs6DU1gTU8zYDHDiWLSip45Egwq3plLHzPn27NgvzL2r1LMPC1vdqh98sQxtqj4A== - lcid@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/lcid/-/lcid-1.0.0.tgz#308accafa0bc483a3867b4b6f2b9506251d1b835" @@ -1563,17 +1495,6 @@ log-update@^4.0.0: slice-ansi "^4.0.0" wrap-ansi "^6.2.0" -logform@^2.2.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/logform/-/logform-2.3.0.tgz#a3997a05985de2ebd325ae0d166dffc9c6fe6b57" - integrity sha512-graeoWUH2knKbGthMtuG1EfaSPMZFZBIrhuJHhkS5ZseFBrc7DupCzihOQAzsK/qIKPQaPJ/lFQFctILUY5ARQ== - dependencies: - colors "^1.2.1" - fecha "^4.2.0" - ms "^2.1.1" - safe-stable-stringify "^1.1.0" - triple-beam "^1.3.0" - long@~3: version "3.2.0" resolved "https://registry.yarnpkg.com/long/-/long-3.2.0.tgz#d821b7138ca1cb581c172990ef14db200b5c474b" @@ -1766,13 +1687,6 @@ once@^1.3.0, once@^1.3.1, once@^1.4.0: dependencies: wrappy "1" -one-time@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/one-time/-/one-time-1.0.0.tgz#e06bc174aed214ed58edede573b433bbf827cb45" - integrity sha512-5DXOiRKwuSEcQ/l0kGCF6Q3jcADFv5tSmRaJck/OqkVFcOzutB134KRSfF0xDrL39MNnqxbHBbUUcjZIhTgb2g== - dependencies: - fn.name "1.x.x" - onetime@^5.1.0, onetime@^5.1.2: version "5.1.2" resolved "https://registry.yarnpkg.com/onetime/-/onetime-5.1.2.tgz#d0e96ebb56b07476df1dd9c4806e5237985ca45e" @@ -1953,7 +1867,7 @@ quick-lru@^5.1.1: resolved "https://registry.yarnpkg.com/quick-lru/-/quick-lru-5.1.1.tgz#366493e6b3e42a3a6885e2e99d18f80fb7a8c932" integrity sha512-WuyALRjWPDGtt/wzJiadO5AXY+8hZ80hVpe6MyivgraREW751X3SbhRvG3eLKOYN+8VEvqLcf3wdnt44Z4S4SA== -readable-stream@^2.0.6, readable-stream@^2.3.7: +readable-stream@^2.0.6: version "2.3.7" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.7.tgz#1eca1cf711aef814c04f62252a36a62f6cb23b57" integrity sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw== @@ -1966,15 +1880,6 @@ readable-stream@^2.0.6, readable-stream@^2.3.7: string_decoder "~1.1.1" util-deprecate "~1.0.1" -readable-stream@^3.4.0: - version "3.6.0" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.6.0.tgz#337bbda3adc0706bd3e024426a286d4b4b2c9198" - integrity sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA== - dependencies: - inherits "^2.0.3" - string_decoder "^1.1.1" - util-deprecate "^1.0.1" - readdirp@~3.6.0: version "3.6.0" resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.6.0.tgz#74a370bd857116e245b29cc97340cd431a02a6c7" @@ -2058,7 +1963,7 @@ rxjs@^6.6.0, rxjs@^6.6.7: dependencies: tslib "^1.9.0" -safe-buffer@^5.0.1, safe-buffer@~5.2.0: +safe-buffer@^5.0.1: version "5.2.1" resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== @@ -2068,11 +1973,6 @@ safe-buffer@~5.1.0, safe-buffer@~5.1.1: resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== -safe-stable-stringify@^1.1.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/safe-stable-stringify/-/safe-stable-stringify-1.1.1.tgz#c8a220ab525cd94e60ebf47ddc404d610dc5d84a" - integrity sha512-ERq4hUjKDbJfE4+XtZLFPCDi8Vb1JqaxAPTxWFLBx8XcAlf9Bda/ZJdVezs/NAfsMQScyIlUMx+Yeu7P7rx5jw== - "safer-buffer@>= 2.1.2 < 3": version "2.1.2" resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" @@ -2134,13 +2034,6 @@ signal-exit@^3.0.0, signal-exit@^3.0.2, signal-exit@^3.0.3: resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.3.tgz#a1410c2edd8f077b08b4e253c8eacfcaf057461c" integrity sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA== -simple-swizzle@^0.2.2: - version "0.2.2" - resolved "https://registry.yarnpkg.com/simple-swizzle/-/simple-swizzle-0.2.2.tgz#a4da6b635ffcccca33f70d17cb92592de95e557a" - integrity sha1-pNprY1/8zMoz9w0Xy5JZLeleVXo= - dependencies: - is-arrayish "^0.3.1" - slice-ansi@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-2.1.0.tgz#cacd7693461a637a5788d92a7dd4fba068e81636" @@ -2191,11 +2084,6 @@ sprintf-js@~1.0.2: resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw= -stack-trace@0.0.x: - version "0.0.10" - resolved "https://registry.yarnpkg.com/stack-trace/-/stack-trace-0.0.10.tgz#547c70b347e8d32b4e108ea1a2a159e5fdde19c0" - integrity sha1-VHxws0fo0ytOEI6hoqFZ5f3eGcA= - streamsearch@0.1.2: version "0.1.2" resolved "https://registry.yarnpkg.com/streamsearch/-/streamsearch-0.1.2.tgz#808b9d0e56fc273d809ba57338e929919a1a9f1a" @@ -2246,13 +2134,6 @@ string-width@^4.1.0, string-width@^4.2.0: is-fullwidth-code-point "^3.0.0" strip-ansi "^6.0.0" -string_decoder@^1.1.1: - version "1.3.0" - resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.3.0.tgz#42f114594a46cf1a8e30b0a84f56c78c3edac21e" - integrity sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA== - dependencies: - safe-buffer "~5.2.0" - string_decoder@~1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.1.1.tgz#9cf1611ba62685d7030ae9e4ba34149c3af03fc8" @@ -2360,11 +2241,6 @@ tdigest@^0.1.1: dependencies: bintrees "1.0.1" -text-hex@1.0.x: - version "1.0.0" - resolved "https://registry.yarnpkg.com/text-hex/-/text-hex-1.0.0.tgz#69dc9c1b17446ee79a92bf5b884bb4b9127506f5" - integrity sha512-uuVGNWzgJ4yhRaNSiubPY7OjISw4sw4E5Uv0wbjp+OzcbmVU/rsT8ujgcXJhn9ypzsgr5vlzpPqP+MBBKcGvbg== - text-table@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" @@ -2394,11 +2270,6 @@ tree-kill@^1.2.2: resolved "https://registry.yarnpkg.com/tree-kill/-/tree-kill-1.2.2.tgz#4ca09a9092c88b73a7cdc5e8a01b507b0790a0cc" integrity sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A== -triple-beam@^1.2.0, triple-beam@^1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/triple-beam/-/triple-beam-1.3.0.tgz#a595214c7298db8339eeeee083e4d10bd8cb8dd9" - integrity sha512-XrHUvV5HpdLmIj4uVMxHggLbFSZYIn7HEWsqePZcI50pco+MPqJ50wMGY794X7AOOhxOBAjbkqfAbEe/QMp2Lw== - ts-node-dev@^1.0.0-pre.44: version "1.1.8" resolved "https://registry.yarnpkg.com/ts-node-dev/-/ts-node-dev-1.1.8.tgz#95520d8ab9d45fffa854d6668e2f8f9286241066" @@ -2482,7 +2353,7 @@ uri-js@^4.2.2: dependencies: punycode "^2.1.0" -util-deprecate@^1.0.1, util-deprecate@~1.0.1: +util-deprecate@~1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" integrity sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8= @@ -2531,29 +2402,6 @@ window-size@^0.1.4: resolved "https://registry.yarnpkg.com/window-size/-/window-size-0.1.4.tgz#f8e1aa1ee5a53ec5bf151ffa09742a6ad7697876" integrity sha1-+OGqHuWlPsW/FR/6CXQqatdpeHY= -winston-transport@^4.4.0: - version "4.4.0" - resolved "https://registry.yarnpkg.com/winston-transport/-/winston-transport-4.4.0.tgz#17af518daa690d5b2ecccaa7acf7b20ca7925e59" - integrity sha512-Lc7/p3GtqtqPBYYtS6KCN3c77/2QCev51DvcJKbkFPQNoj1sinkGwLGFDxkXY9J6p9+EPnYs+D90uwbnaiURTw== - dependencies: - readable-stream "^2.3.7" - triple-beam "^1.2.0" - -winston@^3.3.3: - version "3.3.3" - resolved "https://registry.yarnpkg.com/winston/-/winston-3.3.3.tgz#ae6172042cafb29786afa3d09c8ff833ab7c9170" - integrity sha512-oEXTISQnC8VlSAKf1KYSSd7J6IWuRPQqDdo8eoRNaYKLvwSb5+79Z3Yi1lrl6KDpU6/VWaxpakDAtb1oQ4n9aw== - dependencies: - "@dabh/diagnostics" "^2.0.2" - async "^3.1.0" - is-stream "^2.0.0" - logform "^2.2.0" - one-time "^1.0.0" - readable-stream "^3.4.0" - stack-trace "0.0.x" - triple-beam "^1.3.0" - winston-transport "^4.4.0" - word-wrap@~1.2.3: version "1.2.3" resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.3.tgz#610636f6b1f703891bd34771ccb17fb93b47079c" diff --git a/yarn.lock b/yarn.lock index adbed748..b9698f61 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,7 +2,6 @@ # yarn lockfile v1 -husky@^7.0.1: - version "7.0.4" - resolved "https://registry.yarnpkg.com/husky/-/husky-7.0.4.tgz#242048245dc49c8fb1bf0cc7cfb98dd722531535" - integrity sha512-vbaCKN2QLtP/vD4yvs6iz6hBEo6wkSzs8HpRah1Z6aGmF2KW5PdYuAd7uX5a+OyBZHBhd+TFLqgjUgytQr4RvQ== +"husky@^6.0.0": + "resolved" "https://registry.npmjs.org/husky/-/husky-6.0.0.tgz" + "version" "6.0.0" From 065404758b7b3920bad1c42417cae564b979e0d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Wed, 24 Nov 2021 16:22:26 +0100 Subject: [PATCH 14/18] Making sure pusher and admin are started in CI --- .github/workflows/end_to_end_tests.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/end_to_end_tests.yml b/.github/workflows/end_to_end_tests.yml index 4360d5e1..e931f6c7 100644 --- a/.github/workflows/end_to_end_tests.yml +++ b/.github/workflows/end_to_end_tests.yml @@ -32,6 +32,12 @@ jobs: - name: "Wait for environment to build (and downloading testcafe image)" run: (docker-compose -f docker-compose.testcafe.yml pull &) && docker-compose logs -f --tail=0 front | grep -m 1 "Compiled successfully" + - name: "Wait for back start" + run: docker-compose logs -f back | grep -m 1 "WorkAdventure HTTP API starting on port" + + - name: "Wait for pusher start" + run: docker-compose logs -f pusher | grep -m 1 "WorkAdventure starting on port" + - name: "Run tests" run: docker-compose -f docker-compose.testcafe.yml up --exit-code-from testcafe From d8c10ce10a63dfc7dc07f1622deb53638144c0a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Wed, 24 Nov 2021 16:32:37 +0100 Subject: [PATCH 15/18] CI fix --- .github/workflows/end_to_end_tests.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/end_to_end_tests.yml b/.github/workflows/end_to_end_tests.yml index e931f6c7..8f0e679f 100644 --- a/.github/workflows/end_to_end_tests.yml +++ b/.github/workflows/end_to_end_tests.yml @@ -32,6 +32,9 @@ jobs: - name: "Wait for environment to build (and downloading testcafe image)" run: (docker-compose -f docker-compose.testcafe.yml pull &) && docker-compose logs -f --tail=0 front | grep -m 1 "Compiled successfully" + - name: "temp debug: display logs" + run: docker-compose logs + - name: "Wait for back start" run: docker-compose logs -f back | grep -m 1 "WorkAdventure HTTP API starting on port" From d1122d75ecf6998c71b5560c57c5c9ff9961191b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Wed, 24 Nov 2021 16:59:22 +0100 Subject: [PATCH 16/18] Fixing CI --- .github/workflows/end_to_end_tests.yml | 6 +++--- back/src/Services/Logger.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/end_to_end_tests.yml b/.github/workflows/end_to_end_tests.yml index 8f0e679f..bd9a7f47 100644 --- a/.github/workflows/end_to_end_tests.yml +++ b/.github/workflows/end_to_end_tests.yml @@ -30,16 +30,16 @@ jobs: run: docker-compose up -d - name: "Wait for environment to build (and downloading testcafe image)" - run: (docker-compose -f docker-compose.testcafe.yml pull &) && docker-compose logs -f --tail=0 front | grep -m 1 "Compiled successfully" + run: (docker-compose -f docker-compose.testcafe.yml pull &) && docker-compose logs -f --tail=0 front | grep -q "Compiled successfully" - name: "temp debug: display logs" run: docker-compose logs - name: "Wait for back start" - run: docker-compose logs -f back | grep -m 1 "WorkAdventure HTTP API starting on port" + run: docker-compose logs -f back | grep -q "WorkAdventure HTTP API starting on port" - name: "Wait for pusher start" - run: docker-compose logs -f pusher | grep -m 1 "WorkAdventure starting on port" + run: docker-compose logs -f pusher | grep -q "WorkAdventure starting on port" - name: "Run tests" run: docker-compose -f docker-compose.testcafe.yml up --exit-code-from testcafe diff --git a/back/src/Services/Logger.ts b/back/src/Services/Logger.ts index e19f60d1..79f81472 100644 --- a/back/src/Services/Logger.ts +++ b/back/src/Services/Logger.ts @@ -4,7 +4,7 @@ const logger = winston.createLogger({ transports: [ new winston.transports.Console({ format: winston.format.combine( - winston.format.colorize(), + //winston.format.colorize(), winston.format.timestamp(), winston.format.align(), winston.format.printf((info) => `${info.timestamp} ${info.level}: ${info.message}`) From 257162c4514eb1985c7d81aa01dd34a96fc08d8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Wed, 24 Nov 2021 17:02:11 +0100 Subject: [PATCH 17/18] Fixing prettier --- front/src/Administration/AnalyticsClient.ts | 74 ++++++++----------- front/src/Api/IframeListener.ts | 2 +- front/src/Connexion/LocalUserStore.ts | 4 +- front/src/Phaser/Components/Loader.ts | 24 ++++-- .../src/Phaser/Login/SelectCharacterScene.ts | 2 +- 5 files changed, 53 insertions(+), 53 deletions(-) diff --git a/front/src/Administration/AnalyticsClient.ts b/front/src/Administration/AnalyticsClient.ts index ee85e8f4..fb2b604b 100644 --- a/front/src/Administration/AnalyticsClient.ts +++ b/front/src/Administration/AnalyticsClient.ts @@ -4,7 +4,7 @@ declare let window: any; class AnalyticsClient { // eslint-disable-next-line @typescript-eslint/no-explicit-any - private posthogPromise: Promise|undefined; + private posthogPromise: Promise | undefined; constructor() { if (POSTHOG_API_KEY && POSTHOG_URL) { @@ -18,74 +18,64 @@ class AnalyticsClient { } identifyUser(uuid: string, email: string | null) { - this.posthogPromise - ?.then((posthog) => { - posthog.identify(uuid, { uuid, email, wa: true }); - }); + this.posthogPromise?.then((posthog) => { + posthog.identify(uuid, { uuid, email, wa: true }); + }); } loggedWithSso() { - this.posthogPromise - ?.then((posthog) => { - posthog.capture("wa-logged-sso"); - }); + this.posthogPromise?.then((posthog) => { + posthog.capture("wa-logged-sso"); + }); } loggedWithToken() { - this.posthogPromise - ?.then((posthog) => { - posthog.capture("wa-logged-token"); - }); + this.posthogPromise?.then((posthog) => { + posthog.capture("wa-logged-token"); + }); } enteredRoom(roomId: string, roomGroup: string | null) { - this.posthogPromise - ?.then((posthog) => { - posthog.capture("$pageView", { roomId, roomGroup }); - posthog.capture("enteredRoom"); - }); + this.posthogPromise?.then((posthog) => { + posthog.capture("$pageView", { roomId, roomGroup }); + posthog.capture("enteredRoom"); + }); } openedMenu() { - this.posthogPromise - ?.then((posthog) => { - posthog.capture("wa-opened-menu"); - }); + this.posthogPromise?.then((posthog) => { + posthog.capture("wa-opened-menu"); + }); } launchEmote(emote: string) { - this.posthogPromise - ?.then((posthog) => { - posthog.capture("wa-emote-launch", { emote }); - }); + this.posthogPromise?.then((posthog) => { + posthog.capture("wa-emote-launch", { emote }); + }); } enteredJitsi(roomName: string, roomId: string) { - this.posthogPromise - ?.then((posthog) => { - posthog.capture("wa-entered-jitsi", { roomName, roomId }); - }); + this.posthogPromise?.then((posthog) => { + posthog.capture("wa-entered-jitsi", { roomName, roomId }); + }); } validationName() { - this.posthogPromise - ?.then((posthog) => { - posthog.capture("wa-name-validation"); - }); + this.posthogPromise?.then((posthog) => { + posthog.capture("wa-name-validation"); + }); } validationWoka(scene: string) { - this.posthogPromise - ?.then((posthog) => { - posthog.capture("wa-woka-validation", { scene }); - }); + this.posthogPromise?.then((posthog) => { + posthog.capture("wa-woka-validation", { scene }); + }); } validationVideo() { - this.posthogPromise - ?.then((posthog) => { - posthog.capture("wa-video-validation"); - }); + this.posthogPromise?.then((posthog) => { + posthog.capture("wa-video-validation"); + }); } } export const analyticsClient = new AnalyticsClient(); diff --git a/front/src/Api/IframeListener.ts b/front/src/Api/IframeListener.ts index 871ec3b9..f30ce80c 100644 --- a/front/src/Api/IframeListener.ts +++ b/front/src/Api/IframeListener.ts @@ -49,7 +49,7 @@ class IframeListener { public readonly openTabStream = this._openTabStream.asObservable(); private readonly _loadPageStream: Subject = new Subject(); - public readonly loadPageStream = this._loadPageStream.asObservable() + public readonly loadPageStream = this._loadPageStream.asObservable(); private readonly _disablePlayerControlStream: Subject = new Subject(); public readonly disablePlayerControlStream = this._disablePlayerControlStream.asObservable(); diff --git a/front/src/Connexion/LocalUserStore.ts b/front/src/Connexion/LocalUserStore.ts index a95618ba..ac57c3c7 100644 --- a/front/src/Connexion/LocalUserStore.ts +++ b/front/src/Connexion/LocalUserStore.ts @@ -122,7 +122,7 @@ class LocalUserStore { setLastRoomUrl(roomUrl: string): void { localStorage.setItem(lastRoomUrl, roomUrl.toString()); - if ('caches' in window) { + if ("caches" in window) { caches.open(cacheAPIIndex).then((cache) => { const stringResponse = new Response(JSON.stringify({ roomUrl })); cache.put(`/${lastRoomUrl}`, stringResponse); @@ -135,7 +135,7 @@ class LocalUserStore { ); } getLastRoomUrlCacheApi(): Promise { - if (!('caches' in window)) { + if (!("caches" in window)) { return Promise.resolve(undefined); } return caches.open(cacheAPIIndex).then((cache) => { diff --git a/front/src/Phaser/Components/Loader.ts b/front/src/Phaser/Components/Loader.ts index 0534aa91..e013e758 100644 --- a/front/src/Phaser/Components/Loader.ts +++ b/front/src/Phaser/Components/Loader.ts @@ -13,11 +13,10 @@ export class Loader { private progressContainer!: Phaser.GameObjects.Graphics; private progress!: Phaser.GameObjects.Graphics; private progressAmount: number = 0; - private logo: Phaser.GameObjects.Image|undefined; + private logo: Phaser.GameObjects.Image | undefined; private loadingText: Phaser.GameObjects.Text | null = null; - public constructor(private scene: Phaser.Scene) { - } + public constructor(private scene: Phaser.Scene) {} public addLoader(): void { // If there is nothing to load, do not display the loader. @@ -30,11 +29,19 @@ export class Loader { const promiseLoadLogoTexture = new Promise((res) => { if (this.scene.load.textureManager.exists(LogoNameIndex)) { return res( - this.logo = this.scene.add.image(this.scene.game.renderer.width / 2, this.scene.game.renderer.height / 2 - 150, LogoNameIndex) + (this.logo = this.scene.add.image( + this.scene.game.renderer.width / 2, + this.scene.game.renderer.height / 2 - 150, + LogoNameIndex + )) ); } else { //add loading if logo image is not ready - this.loadingText = this.scene.add.text(this.scene.game.renderer.width / 2, this.scene.game.renderer.height / 2 - 50, TextName); + this.loadingText = this.scene.add.text( + this.scene.game.renderer.width / 2, + this.scene.game.renderer.height / 2 - 50, + TextName + ); } this.scene.load.spritesheet(LogoNameIndex, LogoResource, LogoFrame); this.scene.load.once(`filecomplete-spritesheet-${LogoNameIndex}`, () => { @@ -42,7 +49,11 @@ export class Loader { this.loadingText.destroy(); } return res( - this.logo = this.scene.add.image(this.scene.game.renderer.width / 2, this.scene.game.renderer.height / 2 - 150, LogoNameIndex) + (this.logo = this.scene.add.image( + this.scene.game.renderer.width / 2, + this.scene.game.renderer.height / 2 - 150, + LogoNameIndex + )) ); }); }); @@ -72,7 +83,6 @@ export class Loader { }); } - public removeLoader(): void { if (this.scene.load.textureManager.exists(LogoNameIndex)) { this.scene.load.textureManager.remove(LogoNameIndex); diff --git a/front/src/Phaser/Login/SelectCharacterScene.ts b/front/src/Phaser/Login/SelectCharacterScene.ts index d9861b20..64fa9791 100644 --- a/front/src/Phaser/Login/SelectCharacterScene.ts +++ b/front/src/Phaser/Login/SelectCharacterScene.ts @@ -4,7 +4,7 @@ import { EnableCameraSceneName } from "./EnableCameraScene"; import { CustomizeSceneName } from "./CustomizeScene"; import { localUserStore } from "../../Connexion/LocalUserStore"; import { loadAllDefaultModels } from "../Entity/PlayerTexturesLoadingManager"; -import { Loader} from "../Components/Loader"; +import { Loader } from "../Components/Loader"; import type { BodyResourceDescriptionInterface } from "../Entity/PlayerTextures"; import { AbstractCharacterScene } from "./AbstractCharacterScene"; import { areCharacterLayersValid } from "../../Connexion/LocalUser"; From 445599416c480984cdc0ecc5ba0ba05e675e3fb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Wed, 24 Nov 2021 17:24:11 +0100 Subject: [PATCH 18/18] Commenting waiting as this does not work for some reason --- .github/workflows/end_to_end_tests.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/end_to_end_tests.yml b/.github/workflows/end_to_end_tests.yml index bd9a7f47..a7b3ecfb 100644 --- a/.github/workflows/end_to_end_tests.yml +++ b/.github/workflows/end_to_end_tests.yml @@ -32,14 +32,14 @@ jobs: - name: "Wait for environment to build (and downloading testcafe image)" run: (docker-compose -f docker-compose.testcafe.yml pull &) && docker-compose logs -f --tail=0 front | grep -q "Compiled successfully" - - name: "temp debug: display logs" - run: docker-compose logs - - - name: "Wait for back start" - run: docker-compose logs -f back | grep -q "WorkAdventure HTTP API starting on port" - - - name: "Wait for pusher start" - run: docker-compose logs -f pusher | grep -q "WorkAdventure starting on port" +# - name: "temp debug: display logs" +# run: docker-compose logs +# +# - name: "Wait for back start" +# run: docker-compose logs -f back | grep -q "WorkAdventure HTTP API starting on port" +# +# - name: "Wait for pusher start" +# run: docker-compose logs -f pusher | grep -q "WorkAdventure starting on port" - name: "Run tests" run: docker-compose -f docker-compose.testcafe.yml up --exit-code-from testcafe