Skip to content

Latest commit

 

History

History
23 lines (16 loc) · 937 Bytes

messagechanneladapter.md

File metadata and controls

23 lines (16 loc) · 937 Bytes

MessageChannelAdapter

MessageChannelAdapter is a small utility function that turns string-based communication channels – like a WebSocket, RTCDataChannel or PresentationConnection – into a Comlink-compatible postMessage-based API that can transfer MessagePorts.

Usage

See the examples, specifically WebRTC and Presentation API.

API

MessageChannelAdapter.wrap(endpoint)

wrap returns a MessagePort that serializes messages using JSON.stringify and handles transferred MessagePorts automatically. endpoint is expected to have send and addEventListener.