jumpstorm/engine/network/index.ts

38 lines
708 B
TypeScript
Raw Normal View History

2023-08-23 21:44:59 -04:00
export enum MessageType {
2023-08-25 18:48:17 -04:00
NEW_ENTITIES = 'NEW_ENTITIES',
REMOVE_ENTITIES = 'REMOVE_ENTITIES',
2023-08-26 19:55:27 -04:00
UPDATE_ENTITIES = 'UPDATE_ENTITIES',
NEW_INPUT = 'NEW_INPUT',
REMOVE_INPUT = 'REMOVE_INPUT'
2023-08-23 21:44:59 -04:00
}
export type EntityAddBody = {
entityName: string;
2023-08-26 19:55:27 -04:00
id: string;
args: Record<string, any>;
};
export type EntityUpdateBody = {
id: string;
args: Record<string, any>;
2023-08-23 21:44:59 -04:00
};
export type Message = {
type: MessageType;
body: any;
};
export interface MessageQueueProvider {
getNewMessages(): Message[];
clearMessages(): void;
}
export interface MessagePublisher {
addMessage(message: Message): void;
publish(): void;
}
export interface MessageProcessor {
process(message: Message): void;
}