Adding a warning when editing a map locally.

This commit is contained in:
David Négrier 2021-07-21 16:29:38 +02:00
parent f435cecfdc
commit aa19e8a7cd

View File

@ -9,6 +9,7 @@ import {
BatchToPusherMessage, BatchToPusherMessage,
BatchToPusherRoomMessage, BatchToPusherRoomMessage,
EmoteEventMessage, EmoteEventMessage,
ErrorMessage,
JoinRoomMessage, JoinRoomMessage,
SubToPusherRoomMessage, SubToPusherRoomMessage,
VariableMessage, VariableMessage,
@ -24,6 +25,7 @@ import { mapFetcher } from "../Services/MapFetcher";
import { VariablesManager } from "../Services/VariablesManager"; import { VariablesManager } from "../Services/VariablesManager";
import { ADMIN_API_URL } from "../Enum/EnvironmentVariable"; import { ADMIN_API_URL } from "../Enum/EnvironmentVariable";
import { LocalUrlError } from "../Services/LocalUrlError"; import { LocalUrlError } from "../Services/LocalUrlError";
import { emitErrorOnRoomSocket } from "../Services/MessageHelpers";
export type ConnectCallback = (user: User, group: Group) => void; export type ConnectCallback = (user: User, group: Group) => void;
export type DisconnectCallback = (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. // 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. // In this case, let's bypass the server-side checks completely.
// 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.
// FIXME: find a way to send a warning to the client side setTimeout(() => {
// FIXME: find a way to send a warning to the client side for (const roomListener of this.roomListeners) {
// FIXME: find a way to send a warning to the client side 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); const variablesManager = new VariablesManager(this.roomUrl, null);
variablesManager variablesManager
.init() .init()