@tldraw/sync-core
Version:
tldraw infinite canvas SDK (multiplayer sync).
23 lines (22 loc) • 572 B
JavaScript
class ServerSocketAdapter {
constructor(opts) {
this.opts = opts;
}
// eslint-disable-next-line no-restricted-syntax
get isOpen() {
return this.opts.ws.readyState === 1;
}
// see TLRoomSocket for details on why this accepts a union and not just arrays
sendMessage(msg) {
const message = JSON.stringify(msg);
this.opts.onBeforeSendMessage?.(msg, message);
this.opts.ws.send(message);
}
close(code, reason) {
this.opts.ws.close(code, reason);
}
}
export {
ServerSocketAdapter
};
//# sourceMappingURL=ServerSocketAdapter.mjs.map