* Advance the tracked cursor from a durable event envelope (seq + epoch). * Volatile frames are skipped (their seq is the same watermark, and a * volatile frame can never carry a NEWER seq than the last durable one).
(frame: Record<string, unknown>)
| 451 | * volatile frame can never carry a NEWER seq than the last durable one). |
| 452 | */ |
| 453 | private trackCursor(frame: Record<string, unknown>): void { |
| 454 | if (frame['volatile'] === true) return; |
| 455 | const sid = frame['session_id']; |
| 456 | const seq = frame['seq']; |
| 457 | if (typeof sid !== 'string' || typeof seq !== 'number') return; |
| 458 | const existing = this.subscriptions.get(sid); |
| 459 | if (!existing) return; // not a session we manage |
| 460 | if (seq <= existing.seq && existing.epoch !== undefined) return; |
| 461 | const epoch = typeof frame['epoch'] === 'string' ? (frame['epoch'] as string) : existing.epoch; |
| 462 | this.subscriptions.set(sid, { seq: Math.max(seq, existing.seq), epoch }); |
| 463 | } |
| 464 | |
| 465 | private send(msg: unknown): void { |
| 466 | if (!this.ws || this.ws.readyState !== WebSocket.OPEN) return; |
no test coverage detected