Adding batched messages + the notion of notifier / zones (not plugged in the system yet)
This commit is contained in:
parent
1879c550c4
commit
9b702c75e3
13 changed files with 518 additions and 22 deletions
|
@ -2,6 +2,7 @@ import {Socket} from "socket.io";
|
|||
import {PointInterface} from "./PointInterface";
|
||||
import {Identificable} from "./Identificable";
|
||||
import {TokenInterface} from "../../Controller/AuthenticateController";
|
||||
import {ViewportInterface} from "_Model/Websocket/ViewportMessage";
|
||||
|
||||
export interface ExSocketInterface extends Socket, Identificable {
|
||||
token: string;
|
||||
|
@ -11,5 +12,12 @@ export interface ExSocketInterface extends Socket, Identificable {
|
|||
name: string;
|
||||
characterLayers: string[];
|
||||
position: PointInterface;
|
||||
viewport: ViewportInterface;
|
||||
isArtillery: boolean; // Whether this socket is opened by Artillery for load testing (hack)
|
||||
/**
|
||||
* Pushes an event that will be sent in the next batch of events
|
||||
*/
|
||||
emitInBatch: (event: string | symbol, payload: any) => void;
|
||||
batchedMessages: Array<{ event: string | symbol, payload: any }>;
|
||||
batchTimeout: NodeJS.Timeout|null;
|
||||
}
|
||||
|
|
11
back/src/Model/Websocket/UserMovesMessage.ts
Normal file
11
back/src/Model/Websocket/UserMovesMessage.ts
Normal file
|
@ -0,0 +1,11 @@
|
|||
import * as tg from "generic-type-guard";
|
||||
import {isPointInterface} from "./PointInterface";
|
||||
import {isViewport} from "./ViewportMessage";
|
||||
|
||||
|
||||
export const isUserMovesInterface =
|
||||
new tg.IsInterface().withProperties({
|
||||
position: isPointInterface,
|
||||
viewport: isViewport,
|
||||
}).get();
|
||||
export type UserMovesInterface = tg.GuardedType<typeof isUserMovesInterface>;
|
10
back/src/Model/Websocket/ViewportMessage.ts
Normal file
10
back/src/Model/Websocket/ViewportMessage.ts
Normal file
|
@ -0,0 +1,10 @@
|
|||
import * as tg from "generic-type-guard";
|
||||
|
||||
export const isViewport =
|
||||
new tg.IsInterface().withProperties({
|
||||
left: tg.isNumber,
|
||||
top: tg.isNumber,
|
||||
right: tg.isNumber,
|
||||
bottom: tg.isNumber,
|
||||
}).get();
|
||||
export type ViewportInterface = tg.GuardedType<typeof isViewport>;
|
Loading…
Add table
Add a link
Reference in a new issue