@playlive/realtime-pipeline
    Preparing search index...

    Function createPipelineConnection

    • Create a framework-agnostic WebSocket connection bound to a vanilla Zustand pipeline store. Returns an imperative handle plus a typed event emitter — no React, no Solid, no framework coupling.

      Internally manages:

      1. Connection lifecycle. Opens a native WebSocket, handles onopen / onclose / onerror / onmessage by emitting events and updating store._setConnectionState.
      2. Reconnect. Exponential backoff (capped by maxReconnectAttempts) with full jitter. Emits "reconnect-stop" when exhausted.
      3. Identify. 50 ms debounce + 500 ms duplicate-payload suppression
        • 60 s keep-alive re-identify. Identify wiring is registered into the store so any addCampaign / setOverlayInfo / etc. call triggers a fresh identify.
      4. Refresh. Admin-only refresh command, wired into store.refresh() the same way identify is.
      5. Message dispatch. Every incoming frame is fed through processMessage(store, raw) which mutates the store.

      Returns PipelineConnection

      Imperative PipelineConnection handle.

      import { createPipelineStore } from "@playlive/realtime-pipeline/store";
      import { createPipelineConnection } from "@playlive/realtime-pipeline/connection";

      const store = createPipelineStore({ initialCampaignIDs: ["abc-123"] });
      const conn = createPipelineConnection({ store, autoConnect: true });
      conn.on("open", () => console.log("pipeline connected"));
      conn.on("close", (info) => console.log("pipeline closed", info));