(frame: unknown)
| 248 | |
| 249 | /** Outbound client frame (client_hello / subscribe / unsubscribe / abort / pong). */ |
| 250 | export function traceWsOut(frame: unknown): void { |
| 251 | if (!isTraceEnabled()) return; |
| 252 | const f = (frame ?? {}) as Record<string, unknown>; |
| 253 | const type = typeof f['type'] === 'string' ? (f['type'] as string) : '(unknown)'; |
| 254 | const payload = f['payload'] as Record<string, unknown> | undefined; |
| 255 | const sessionId = |
| 256 | typeof payload?.['session_id'] === 'string' ? (payload['session_id'] as string) : undefined; |
| 257 | push({ |
| 258 | source: 'ws', |
| 259 | kind: 'ws:out', |
| 260 | eventType: type, |
| 261 | sessionId, |
| 262 | label: `→ ${type}`, |
| 263 | detail: detailOf(frame), |
| 264 | }); |
| 265 | } |
| 266 | |
| 267 | /** Inbound server frame — control frames and event frames alike. */ |
| 268 | export function traceWsIn(frame: unknown): void { |
no test coverage detected