From 6fcabc57e0a04dad6ea17d91c72cb0bad70f418d Mon Sep 17 00:00:00 2001 From: Kevin Jahns Date: Mon, 21 Mar 2022 13:30:57 +0100 Subject: [PATCH] add documentation --- README.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index bff0fa2..eb8f781 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,9 @@ wsOpts = { // E.g. In nodejs, you could specify WebsocketPolyfill = require('ws') WebsocketPolyfill: Websocket, // Specify an existing Awareness instance - see https://github.com/yjs/y-protocols - awareness: new awarenessProtocol.Awareness(ydoc) + awareness: new awarenessProtocol.Awareness(ydoc), + // Specify the maximum amount to wait between reconnects (we use exponential backoff). + maxBackoffTime: 2500 } ``` @@ -94,6 +96,12 @@ wsOpts = {
Destroy this wsProvider instance. Disconnects from the server and removes all event handlers.
wsProvider.on('sync', function(isSynced: boolean))
Add an event listener for the sync event that is fired when the client received content from the server.
+ wsProvider.on('status', function({ status: 'disconnected' | 'connecting' | 'connected' })) +
Receive updates about the current connection status.
+ wsProvider.on('connection-close', function(WSClosedEvent)) +
Fires when the underlying websocket connection is closed. It forwards the websocket event to this event handler.
+ wsProvider.on('connection-error', function(WSErrorEvent)) +
Fires when the underlying websocket connection closes with an error. It forwards the websocket event to this event handler.
## Websocket Server