workadventure/pusher/src/Model/Websocket/ExSocketInterface.ts

49 lines
1.6 KiB
TypeScript
Raw Normal View History

2021-06-24 10:09:10 +02:00
import { PointInterface } from "./PointInterface";
import { Identificable } from "./Identificable";
import { ViewportInterface } from "_Model/Websocket/ViewportMessage";
import {
BatchMessage,
2021-04-06 18:54:45 +02:00
CompanionMessage,
PusherToBackMessage,
ServerToClientMessage,
2021-06-24 10:09:10 +02:00
SubMessage,
} from "../../Messages/generated/messages_pb";
2021-06-24 10:09:10 +02:00
import { WebSocket } from "uWebSockets.js";
import { ClientDuplexStream } from "grpc";
import { Zone } from "_Model/Zone";
import { CharacterTexture } from "../../Services/AdminApi/CharacterTexture";
export type BackConnection = ClientDuplexStream<PusherToBackMessage, ServerToClientMessage>;
export interface CharacterLayer {
2021-06-24 10:09:10 +02:00
name: string;
url: string | undefined;
}
export interface ExSocketInterface extends WebSocket, Identificable {
token: string;
roomId: string;
//userId: number; // A temporary (autoincremented) identifier for this user
userUuid: string; // A unique identifier for this user
2021-01-15 03:19:58 +01:00
IPAddress: string; // IP address
name: string;
characterLayers: CharacterLayer[];
position: PointInterface;
viewport: ViewportInterface;
2021-04-06 18:54:45 +02:00
companion?: CompanionMessage;
/**
* Pushes an event that will be sent in the next batch of events
*/
emitInBatch: (payload: SubMessage) => void;
batchedMessages: BatchMessage;
2021-06-24 10:09:10 +02:00
batchTimeout: NodeJS.Timeout | null;
disconnecting: boolean;
messages: unknown;
tags: string[];
visitCardUrl: string | null;
textures: CharacterTexture[];
backConnection: BackConnection;
listenedZones: Set<Zone>;
userRoomToken: string | undefined;
}