feat: implement real-time event handling and SSE support; add event publishing and subscription mechanisms
This commit is contained in:
@@ -11,3 +11,5 @@ export * from './util/RandUtil.js';
|
||||
export * from './util/TestRNG.js';
|
||||
export * from './util/sha512.js';
|
||||
export * from './turnDaemon/types.js';
|
||||
export * from './realtime/keys.js';
|
||||
export * from './realtime/types.js';
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
const normalizeProfileName = (profileName: string): string => {
|
||||
const trimmed = profileName.trim();
|
||||
return trimmed.length > 0 ? trimmed : 'unknown';
|
||||
};
|
||||
|
||||
export const buildGameEventChannel = (profileName: string): string => {
|
||||
const normalized = normalizeProfileName(profileName);
|
||||
return `sammo:${normalized}:realtime:events`;
|
||||
};
|
||||
@@ -0,0 +1,18 @@
|
||||
import type { TurnRunResult } from '../turnDaemon/types.js';
|
||||
|
||||
export type MessageTypeKey = 'public' | 'private' | 'national' | 'diplomacy';
|
||||
|
||||
export type RealtimeEvent =
|
||||
| {
|
||||
type: 'turnCompleted';
|
||||
at: string;
|
||||
result: TurnRunResult;
|
||||
}
|
||||
| {
|
||||
type: 'messageCreated';
|
||||
at: string;
|
||||
mailbox: number;
|
||||
msgType: MessageTypeKey;
|
||||
messageId: number;
|
||||
senderId: number;
|
||||
};
|
||||
Reference in New Issue
Block a user