Create a new Loro WebSocket adapter.
Unique identifier for this adapter instance.
URL of the Loro WebSocket server to connect to.
VS Code Webview instance to send messages to.
Connect to the WebSocket server. Establishes a new WebSocket connection if one doesn't already exist. Sets up event handlers for open, message, close, and error events. Messages received while disconnected are queued and sent upon reconnection. Automatically attempts to reconnect with exponential backoff on close.
Void.
Disconnect from the WebSocket server. Cancels any pending reconnection timers and closes the WebSocket connection. Safe to call multiple times; handles null checks internally.
Void.
Clean up resources and prepare for garbage collection. Marks the adapter as disposed, disconnects from the server, and clears the message queue. After disposal, the adapter should not be used.
Void.
Routes incoming webview messages to connect, disconnect, or send handlers.
The message from the webview with type, adapterId, and optional data.
Check if the WebSocket is currently connected and ready to send. Verifies that the WebSocket exists and readyState is 1 (OPEN).
True if connected and ready, false otherwise.
Send a message to the WebSocket server. Supports multiple data types: string (JSON), array (binary/Loro update bytes), or object (JSON). If not connected, messages are queued up to maxQueueSize and sent when connection establishes. Queue overflow is silently dropped to prevent memory issues.
The data to send (string, array, or object).
Void.
WebSocket adapter that runs in the extension (Node.js context). Manages WebSocket connection to Loro collaboration server.