@mocanvas/sync · interface

Transport

interface Transport<R extends UnknownRecord = UnknownRecord>

A duplex channel that carries SyncMessages between peers in one room.

The transport owns serialization and reconnection; the client above it only sees decoded messages. onOpen fires every time the channel becomes usable (including after a reconnect), onClose every time it stops being usable. A transport with neither is treated as open from the moment it is connected.


Methods · 3

close(): void
onMessage(callback: (message: SyncMessage<R>) => void): () => void
send(message: SyncMessage<R>): void

Properties · 2

onClose?(callback: () => void): () => void
onOpen?(callback: () => void): () => void

Mentioned here

mocanvas is built by Symbio. Free for non-commercial, non-profit and development use; commercial use needs an agreement. Not affiliated with or endorsed by tldraw.