feat: refactor realtime event types and payload structure for consistency
This commit is contained in:
@@ -31,13 +31,7 @@ describe('parseRealtimeEvent', () => {
|
||||
const payload: RealtimeEvent = {
|
||||
type: 'turnCompleted',
|
||||
at: '2026-01-01T00:00:00.000Z',
|
||||
result: {
|
||||
lastTurnTime: '2026-01-01T00:00:00.000Z',
|
||||
processedGenerals: 2,
|
||||
processedTurns: 1,
|
||||
durationMs: 1200,
|
||||
partial: false,
|
||||
},
|
||||
lastTurnTime: '2026-01-01T00:00:00.000Z',
|
||||
};
|
||||
const parsed = parseRealtimeEvent(JSON.stringify(payload));
|
||||
|
||||
|
||||
@@ -237,7 +237,7 @@ export const createTurnDaemonRuntime = async (options: TurnDaemonRuntimeOptions)
|
||||
await publishRealtimeEvent({
|
||||
type: 'turnCompleted',
|
||||
at: new Date().toISOString(),
|
||||
result,
|
||||
lastTurnTime: result.lastTurnTime,
|
||||
});
|
||||
} catch {
|
||||
// 실시간 이벤트 전송 실패는 턴 처리 결과에 영향을 주지 않는다.
|
||||
|
||||
@@ -1,18 +1,20 @@
|
||||
import type { TurnRunResult } from '../turnDaemon/types.js';
|
||||
|
||||
export type MessageTypeKey = 'public' | 'private' | 'national' | 'diplomacy';
|
||||
|
||||
export interface TurnCompletedEvent {
|
||||
type: 'turnCompleted';
|
||||
at: string;
|
||||
lastTurnTime: string;
|
||||
}
|
||||
|
||||
export interface MessageCreatedEvent {
|
||||
type: 'messageCreated';
|
||||
at: string;
|
||||
mailbox: number;
|
||||
msgType: MessageTypeKey;
|
||||
messageId: number;
|
||||
senderId: number;
|
||||
}
|
||||
|
||||
export type RealtimeEvent =
|
||||
| {
|
||||
type: 'turnCompleted';
|
||||
at: string;
|
||||
result: TurnRunResult;
|
||||
}
|
||||
| {
|
||||
type: 'messageCreated';
|
||||
at: string;
|
||||
mailbox: number;
|
||||
msgType: MessageTypeKey;
|
||||
messageId: number;
|
||||
senderId: number;
|
||||
};
|
||||
| TurnCompletedEvent
|
||||
| MessageCreatedEvent;
|
||||
|
||||
Reference in New Issue
Block a user