UNPKG

@woosh/meep-engine

Version:

Pure JavaScript game engine. Fully featured and production ready.

33 lines 1.29 kB
/** * Transport adapter that wraps a browser `RTCDataChannel` configured for * unreliable, unordered delivery — the only sane low-latency channel on the web. * * The data channel must be created with `{ ordered: false, maxRetransmits: 0 }` * and reach `readyState === "open"` before this adapter is used. Channel setup * (negotiating the `RTCPeerConnection`, ICE, signalling) is the application's * responsibility; this adapter only handles byte transport. * * Duck-typed against `RTCDataChannel` so the same adapter works with mocks in * tests. The expected interface is: * - `binaryType` (writable; we set it to `'arraybuffer'`) * - `addEventListener(type, handler)` for `'message'`, `'close'`, `'error'` * - `send(ArrayBuffer)` * - `close()` * - `readyState` (read in some debug paths) * * @author Alex Goldring * @copyright Company Named Limited (c) 2025 */ export class WebRTCDataChannelTransport extends Transport { /** * @param {{ data_channel: RTCDataChannel }} options */ constructor({ data_channel }: { data_channel: RTCDataChannel; }); /** @type {RTCDataChannel} */ data_channel: RTCDataChannel; #private; } import { Transport } from "../Transport.js"; //# sourceMappingURL=WebRTCDataChannelTransport.d.ts.map