feat: implement real-time event handling and SSE support; add event publishing and subscription mechanisms

This commit is contained in:
2026-01-17 01:39:06 +00:00
parent f3c0f492be
commit 56b1c40642
13 changed files with 473 additions and 13 deletions
+2
View File
@@ -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';
+9
View File
@@ -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`;
};
+18
View File
@@ -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;
};