add option to specify protocols
This commit is contained in:
parent
630e08eef3
commit
2c3c71e95c
@ -129,7 +129,7 @@ const readMessage = (provider, buf, emitSynced) => {
|
|||||||
*/
|
*/
|
||||||
const setupWS = (provider) => {
|
const setupWS = (provider) => {
|
||||||
if (provider.shouldConnect && provider.ws === null) {
|
if (provider.shouldConnect && provider.ws === null) {
|
||||||
const websocket = new provider._WS(provider.url)
|
const websocket = new provider._WS(provider.url, provider.protocols)
|
||||||
websocket.binaryType = 'arraybuffer'
|
websocket.binaryType = 'arraybuffer'
|
||||||
provider.ws = websocket
|
provider.ws = websocket
|
||||||
provider.wsconnecting = true
|
provider.wsconnecting = true
|
||||||
@ -246,6 +246,7 @@ export class WebsocketProvider extends Observable {
|
|||||||
* @param {boolean} [opts.connect]
|
* @param {boolean} [opts.connect]
|
||||||
* @param {awarenessProtocol.Awareness} [opts.awareness]
|
* @param {awarenessProtocol.Awareness} [opts.awareness]
|
||||||
* @param {Object<string,string>} [opts.params] specify url parameters
|
* @param {Object<string,string>} [opts.params] specify url parameters
|
||||||
|
* @param {Array<string>} [opts.protocols] specify websocket protocols
|
||||||
* @param {typeof WebSocket} [opts.WebSocketPolyfill] Optionall provide a WebSocket polyfill
|
* @param {typeof WebSocket} [opts.WebSocketPolyfill] Optionall provide a WebSocket polyfill
|
||||||
* @param {number} [opts.resyncInterval] Request server state every `resyncInterval` milliseconds
|
* @param {number} [opts.resyncInterval] Request server state every `resyncInterval` milliseconds
|
||||||
* @param {number} [opts.maxBackoffTime] Maximum amount of time to wait before trying to reconnect (we try to reconnect using exponential backoff)
|
* @param {number} [opts.maxBackoffTime] Maximum amount of time to wait before trying to reconnect (we try to reconnect using exponential backoff)
|
||||||
@ -255,6 +256,7 @@ export class WebsocketProvider extends Observable {
|
|||||||
connect = true,
|
connect = true,
|
||||||
awareness = new awarenessProtocol.Awareness(doc),
|
awareness = new awarenessProtocol.Awareness(doc),
|
||||||
params = {},
|
params = {},
|
||||||
|
protocols = [],
|
||||||
WebSocketPolyfill = WebSocket,
|
WebSocketPolyfill = WebSocket,
|
||||||
resyncInterval = -1,
|
resyncInterval = -1,
|
||||||
maxBackoffTime = 2500,
|
maxBackoffTime = 2500,
|
||||||
@ -274,6 +276,7 @@ export class WebsocketProvider extends Observable {
|
|||||||
* @type {Object<string,string>}
|
* @type {Object<string,string>}
|
||||||
*/
|
*/
|
||||||
this.params = params
|
this.params = params
|
||||||
|
this.protocols = protocols
|
||||||
this.roomname = roomname
|
this.roomname = roomname
|
||||||
this.doc = doc
|
this.doc = doc
|
||||||
this._WS = WebSocketPolyfill
|
this._WS = WebSocketPolyfill
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user