# Realtime

Transport framing and real-time fan-out. These compose: the hub delivers over
whatever transport you supply, and the codec is what makes a batch of messages
legible to the receiver.

- [PowerMessageCodec: Versioned binary message framing](../guides/powerMessageCodec.md). Explicit `[version][codec][length][payload]` envelope so a transport never has to _guess_ what it received. Framed `json`/`raw` codecs for byte streams, plus `encodeNativeEnvelope` for the platform structured clone on a `MessagePort`/`Worker`. This is the protocol `PowerPool` speaks by default since 2.0; `decodeInbound` reads either carrier.
- [PowerRealtimeHub: Topic fan-out with slow-consumer control](../guides/powerRealtimeHub.md). Per-subscriber bounded queues and a declared policy (`drop-oldest` / `drop-newest` / `disconnect`) so one slow consumer cannot stall or OOM the process. Transport-agnostic via a `send` adapter; batches over `PowerMessageCodec`.
- [createBroadcastBus: BroadcastChannel bus with per-frame ack and slow-consumer detection](../guides/powerBroadcastBus.md). Adds an application-level ack protocol so a `BroadcastChannel` can carry the hub's slow-consumer contract honestly. One `postMessage` per frame; the receiver acks with a native envelope.
- [PowerMessagePort: `MessagePort` transport adapter for `PowerRealtimeHub`](../guides/powerMessagePort.md). Uses the platform's native structured-clone codec so `Map`, `Set`, `Date`, `BigInt` and cycles survive the boundary without JSON round-tripping. Supplies inbound decoding through `decodeInbound` and safe listener teardown on `dispose()`.
- [PowerWebSocketClient: Reconnecting client with back-pressure](../guides/powerWebSocketClient.md). `WebSocket` has no back-pressure, so this adds it two ways: `bufferedAmount` watermarks (universal, with a backing-off poll and `onPause`/`onResume`) and `WebSocketStream` where available (awaits `writer.ready`). Plus heartbeats with RTT, decorrelated-jitter reconnects, and a connect timeout. Pairs with `PowerRealtimeHub` via `sendFrame`.
- [PowerWebTransportClient: Reconnecting WebTransport client with stream-based back-pressure](../guides/powerWebTransportClient.md). Mirrors the `PowerWebSocketClient` API over WebTransport streams: `send()` and `sendFrame()` await `writer.ready` for natural back-pressure, heartbeats use application-level frames with a deadline, and reconnection uses decorrelated-jitter backoff. Pairs with `PowerRealtimeHub` via `sendFrame`.
- [PowerSocketAdapter: One interface over three socket models](../guides/powerSocketAdapter.md). Normalise a Node `ws` socket, a browser `WebSocket`, or a `WebSocketStream` behind one API. They are genuinely incompatible — a `ws` `message` handler receives `(data, isBinary)`, an `EventTarget` one receives an event object, and a `WebSocketStream` has neither `on`, `readyState`, nor `bufferedAmount` — and the mismatches fail silently. Adds socket-level liveness, per-message rate limiting, and a graceful `drain()` for shutdown. The server-side counterpart to the client above; there is no WebSocket server here, and there should not be.
- [PowerRTCChannel: One `RTCDataChannel` behind the same shape as `PowerSocketAdapter`](../guides/powerRTCChannel.md) — string `readyState` normalised, SCTP's message-size ceiling enforced, and back-pressure that arrives as a push signal instead of a poll timer. A data channel's `readyState` is `'open'`, not `1`, so the `=== READY_STATE.OPEN` guard every other transport satisfies is silently false on a healthy channel. `send()` **throws** above the SCTP ceiling where a `WebSocket` would buffer, which is the one case a hub can actually see — a `false` is invisible to `PowerRealtimeHub`, so watch `sendRefusals`. `binaryType` is already `arraybuffer`, so the framed codec works unchanged; `expectUnreliable` asserts the `ordered:false, maxRetransmits:0` this class cannot set for you.
- [PowerDatagramChannel: Bounded, drop-counting datagram wrapper](../guides/powerDatagramChannel.md). Enforces a hard `maxDatagramSizeBytes` ceiling before the platform sees the datagram, so an oversize frame is refused with a `TypeError` and counted in `stats().oversizeDatagrams` rather than silently discarded. When the internal queue is full, the oldest queued datagram is dropped first and the new one is queued in its place, so the loss is observable in `droppedCount`. This is **not** a hub `send` adapter: `retain` and datagrams contradict each other. Use it directly for bounded, counted datagram delivery, or wrap it in your own adapter that knows how to frame and retain.
- [createWebTransportAdapter: `WebTransportBidirectionalStream` behind the same shape as `PowerSocketAdapter`](../guides/powerWebTransportAdapter.md). Wraps a `WebTransport` session's bidirectional stream and decodes inbound frames with `createFrameDecoder` so split frames do not surface as `RangeError`s at the reader. `maxFrameBytes` is `Infinity`; enforcement is left to `PowerSocketAdapter`'s `maxPayloadSizeBytes`.
- [createSseAdapter: Server-sent events transport adapter for `PowerRealtimeHub`](../guides/powerSseAdapter.md). Bridges the hub's `send(subscriber, frame)` contract to an SSE `Response` stream. Each frame is written as one base64-encoded `data:` line, so binary payloads do not break the event-stream format. Works through every proxy and CDN that supports SSE.
- [WebTransport feature detection](../guides/webTransportSupport.md) — `detectWebTransportSupport()`: a pure probe for what a build actually supports, opening no connection. `reliableOnly` is the flag to branch on, because `reliability`, `getStats()` and `WebTransportSendGroup` are all **not** Baseline; each defaults to `false` rather than optimistic `true`. The transport adapter factory is [`createWebTransportAdapter`](../guides/powerWebTransportAdapter.md).
