From aa19e8a7cdc3c50cdb9fcc4d7781cfbcb6acfc4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Wed, 21 Jul 2021 16:29:38 +0200 Subject: [PATCH] Adding a warning when editing a map locally. --- back/src/Model/GameRoom.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/back/src/Model/GameRoom.ts b/back/src/Model/GameRoom.ts index 2e30bf52..3f355f49 100644 --- a/back/src/Model/GameRoom.ts +++ b/back/src/Model/GameRoom.ts @@ -9,6 +9,7 @@ import { BatchToPusherMessage, BatchToPusherRoomMessage, EmoteEventMessage, + ErrorMessage, JoinRoomMessage, SubToPusherRoomMessage, VariableMessage, @@ -24,6 +25,7 @@ import { mapFetcher } from "../Services/MapFetcher"; import { VariablesManager } from "../Services/VariablesManager"; import { ADMIN_API_URL } from "../Enum/EnvironmentVariable"; import { LocalUrlError } from "../Services/LocalUrlError"; +import { emitErrorOnRoomSocket } from "../Services/MessageHelpers"; export type ConnectCallback = (user: User, group: Group) => void; export type DisconnectCallback = (user: User, group: Group) => void; @@ -452,10 +454,16 @@ export class GameRoom { // If we are trying to load a local URL, we are probably in test mode. // In this case, let's bypass the server-side checks completely. - // FIXME: find a way to send a warning to the client side - // FIXME: find a way to send a warning to the client side - // FIXME: find a way to send a warning to the client side - // FIXME: find a way to send a warning to the client side + // Note: we run this message inside a setTimeout so that the room listeners can have time to connect. + setTimeout(() => { + for (const roomListener of this.roomListeners) { + emitErrorOnRoomSocket( + roomListener, + "You are loading a local map. If you use the scripting API in this map, please be aware that server-side checks and variable persistence is disabled." + ); + } + }, 1000); + const variablesManager = new VariablesManager(this.roomUrl, null); variablesManager .init()