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