y-websocket
Advanced tools
Comparing version
@@ -26,4 +26,5 @@ /** | ||
* @param {number} [opts.maxBackoffTime] Maximum amount of time to wait before trying to reconnect (we try to reconnect using exponential backoff) | ||
* @param {boolean} [opts.disableBc] Disable cross-tab BroadcastChannel communication | ||
*/ | ||
constructor(serverUrl: string, roomname: string, doc: Y.Doc, { connect, awareness, params, WebSocketPolyfill, resyncInterval, maxBackoffTime }?: { | ||
constructor(serverUrl: string, roomname: string, doc: Y.Doc, { connect, awareness, params, WebSocketPolyfill, resyncInterval, maxBackoffTime, disableBc }?: { | ||
connect?: boolean; | ||
@@ -37,2 +38,3 @@ awareness?: awarenessProtocol.Awareness; | ||
maxBackoffTime?: number; | ||
disableBc?: boolean; | ||
} | undefined); | ||
@@ -56,2 +58,3 @@ maxBackoffTime: number; | ||
bcconnected: boolean; | ||
disableBc: boolean; | ||
wsUnsuccessfulReconnects: number; | ||
@@ -58,0 +61,0 @@ messageHandlers: ((arg0: encoding.Encoder, arg1: decoding.Decoder, arg2: WebsocketProvider, arg3: boolean, arg4: number) => void)[]; |
{ | ||
"name": "y-websocket", | ||
"version": "1.4.2", | ||
"version": "1.4.3", | ||
"description": "Websockets provider for Yjs", | ||
@@ -5,0 +5,0 @@ "main": "./dist/y-websocket.cjs", |
@@ -190,4 +190,13 @@ /* | ||
* @param {number} [opts.maxBackoffTime] Maximum amount of time to wait before trying to reconnect (we try to reconnect using exponential backoff) | ||
* @param {boolean} [opts.disableBc] Disable cross-tab BroadcastChannel communication | ||
*/ | ||
constructor (serverUrl, roomname, doc, { connect = true, awareness = new awarenessProtocol.Awareness(doc), params = {}, WebSocketPolyfill = WebSocket, resyncInterval = -1, maxBackoffTime = 2500 } = {}) { | ||
constructor (serverUrl, roomname, doc, { | ||
connect = true, | ||
awareness = new awarenessProtocol.Awareness(doc), | ||
params = {}, | ||
WebSocketPolyfill = WebSocket, | ||
resyncInterval = -1, | ||
maxBackoffTime = 2500, | ||
disableBc = false | ||
} = {}) { | ||
super() | ||
@@ -209,2 +218,3 @@ // ensure that url is always ends with / | ||
this.bcconnected = false | ||
this.disableBc = disableBc | ||
this.wsUnsuccessfulReconnects = 0 | ||
@@ -333,2 +343,5 @@ this.messageHandlers = messageHandlers.slice() | ||
connectBc () { | ||
if (this.disableBc) { | ||
return | ||
} | ||
if (!this.bcconnected) { | ||
@@ -335,0 +348,0 @@ bc.subscribe(this.bcChannel, this._bcSubscriber) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
80858
1.22%1215
2.45%