2021-07-07 11:24:51 +02:00
|
|
|
import type { SignalData } from "simple-peer";
|
|
|
|
import type { RoomConnection } from "./RoomConnection";
|
|
|
|
import type { BodyResourceDescriptionInterface } from "../Phaser/Entity/PlayerTextures";
|
2020-09-25 18:29:22 +02:00
|
|
|
|
2021-07-07 11:24:51 +02:00
|
|
|
export enum EventMessage {
|
2020-11-13 18:00:22 +01:00
|
|
|
CONNECT = "connect",
|
2020-09-25 18:29:22 +02:00
|
|
|
WEBRTC_SIGNAL = "webrtc-signal",
|
|
|
|
WEBRTC_SCREEN_SHARING_SIGNAL = "webrtc-screen-sharing-signal",
|
|
|
|
WEBRTC_START = "webrtc-start",
|
2020-12-03 16:39:44 +01:00
|
|
|
//START_ROOM = "start-room", // From server to client: list of all room users/groups/items
|
2020-09-25 18:29:22 +02:00
|
|
|
JOIN_ROOM = "join-room", // bi-directional
|
|
|
|
USER_POSITION = "user-position", // From client to server
|
|
|
|
USER_MOVED = "user-moved", // From server to client
|
|
|
|
USER_LEFT = "user-left", // From server to client
|
|
|
|
MESSAGE_ERROR = "message-error",
|
|
|
|
WEBRTC_DISCONNECT = "webrtc-disconect",
|
|
|
|
GROUP_CREATE_UPDATE = "group-create-update",
|
|
|
|
GROUP_DELETE = "group-delete",
|
|
|
|
SET_PLAYER_DETAILS = "set-player-details", // Send the name and character to the server (on connect), receive back the id.
|
2021-07-07 11:24:51 +02:00
|
|
|
ITEM_EVENT = "item-event",
|
2020-09-25 18:29:22 +02:00
|
|
|
|
|
|
|
CONNECT_ERROR = "connect_error",
|
2020-12-03 16:39:44 +01:00
|
|
|
CONNECTING_ERROR = "connecting_error",
|
2020-09-25 18:29:22 +02:00
|
|
|
SET_SILENT = "set_silent", // Set or unset the silent mode for this user.
|
|
|
|
SET_VIEWPORT = "set-viewport",
|
|
|
|
BATCH = "batch",
|
2020-10-01 14:11:34 +02:00
|
|
|
|
|
|
|
PLAY_GLOBAL_MESSAGE = "play-global-message",
|
|
|
|
STOP_GLOBAL_MESSAGE = "stop-global-message",
|
2020-10-13 11:39:07 +02:00
|
|
|
|
|
|
|
TELEPORT = "teleport",
|
2020-10-19 19:32:47 +02:00
|
|
|
USER_MESSAGE = "user-message",
|
2020-10-16 19:13:26 +02:00
|
|
|
START_JITSI_ROOM = "start-jitsi-room",
|
2021-07-07 17:17:28 +02:00
|
|
|
SET_VARIABLE = "set-variable",
|
2020-09-25 18:29:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface PointInterface {
|
|
|
|
x: number;
|
|
|
|
y: number;
|
2021-07-07 11:24:51 +02:00
|
|
|
direction: string;
|
2020-09-25 18:29:22 +02:00
|
|
|
moving: boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface MessageUserPositionInterface {
|
|
|
|
userId: number;
|
|
|
|
name: string;
|
2020-10-20 16:39:23 +02:00
|
|
|
characterLayers: BodyResourceDescriptionInterface[];
|
2020-09-25 18:29:22 +02:00
|
|
|
position: PointInterface;
|
2021-07-07 11:24:51 +02:00
|
|
|
visitCardUrl: string | null;
|
|
|
|
companion: string | null;
|
|
|
|
userUuid: string;
|
2020-09-25 18:29:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface MessageUserMovedInterface {
|
|
|
|
userId: number;
|
|
|
|
position: PointInterface;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface MessageUserJoined {
|
|
|
|
userId: number;
|
|
|
|
name: string;
|
2020-10-20 16:39:23 +02:00
|
|
|
characterLayers: BodyResourceDescriptionInterface[];
|
2021-04-02 21:21:11 +02:00
|
|
|
position: PointInterface;
|
2021-06-08 16:30:58 +02:00
|
|
|
visitCardUrl: string | null;
|
2021-07-07 11:24:51 +02:00
|
|
|
companion: string | null;
|
|
|
|
userUuid: string;
|
2020-09-25 18:29:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface PositionInterface {
|
2021-07-07 11:24:51 +02:00
|
|
|
x: number;
|
|
|
|
y: number;
|
2020-09-25 18:29:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface GroupCreatedUpdatedMessageInterface {
|
2021-07-07 11:24:51 +02:00
|
|
|
position: PositionInterface;
|
|
|
|
groupId: number;
|
|
|
|
groupSize: number;
|
2020-09-25 18:29:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface WebRtcDisconnectMessageInterface {
|
2021-07-07 11:24:51 +02:00
|
|
|
userId: number;
|
2020-09-25 18:29:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface WebRtcSignalReceivedMessageInterface {
|
2021-07-07 11:24:51 +02:00
|
|
|
userId: number;
|
|
|
|
signal: SignalData;
|
|
|
|
webRtcUser: string | undefined;
|
|
|
|
webRtcPassword: string | undefined;
|
2020-09-25 18:29:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface ViewportInterface {
|
2021-07-07 11:24:51 +02:00
|
|
|
left: number;
|
|
|
|
top: number;
|
|
|
|
right: number;
|
|
|
|
bottom: number;
|
2020-09-25 18:29:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface ItemEventMessageInterface {
|
2021-07-07 11:24:51 +02:00
|
|
|
itemId: number;
|
|
|
|
event: string;
|
|
|
|
state: unknown;
|
|
|
|
parameters: unknown;
|
2020-09-25 18:29:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface RoomJoinedMessageInterface {
|
2020-11-13 18:00:22 +01:00
|
|
|
//users: MessageUserPositionInterface[],
|
|
|
|
//groups: GroupCreatedUpdatedMessageInterface[],
|
2021-07-07 11:24:51 +02:00
|
|
|
items: { [itemId: number]: unknown };
|
2021-07-07 17:17:28 +02:00
|
|
|
variables: Map<string, unknown>;
|
2020-10-01 14:11:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface PlayGlobalMessageInterface {
|
2021-07-20 15:16:51 +02:00
|
|
|
type: string;
|
|
|
|
content: string;
|
|
|
|
broadcastToWorld: boolean;
|
|
|
|
}
|
|
|
|
|
2020-12-03 16:39:44 +01:00
|
|
|
export interface OnConnectInterface {
|
2021-07-07 11:24:51 +02:00
|
|
|
connection: RoomConnection;
|
|
|
|
room: RoomJoinedMessageInterface;
|
2020-12-03 16:39:44 +01:00
|
|
|
}
|