Feat(SSE): SSE Session auto-reconnect

This commit is contained in:
2025-05-26 02:36:22 +00:00
committed by Jim Hamill
parent debdf22f15
commit ce0c417ccf
4 changed files with 163 additions and 47 deletions
@@ -1,5 +1,5 @@
import { BaseStore } from './base-store.js';
import { SSEClient } from '../utils/index.js';
import { SSESession } from '../utils/index.js';
import {
Bytes,
Encrypter,
@@ -96,7 +96,7 @@ export class StoreRemoteHTTP extends BaseStore {
// NOTE: SSE only supports text-encoding, so we use Extended JSON instead of msgpackr (which is binary).
// TODO: It would be really nice to somehow be able to support msgpackr for consistency though.
// But, from a bandwidth point of view, this is not crucial: These payloads are "live" payloads (thus, there's not much data).
await SSEClient.from(`${this.baseURL}events`, {
await SSESession.from(`${this.baseURL}events`, {
method: 'POST',
headers,
onMessage: (e) => {