mirror of
https://github.com/amark/gun.git
synced 2025-03-30 15:08:33 +00:00
Setup default option
if wsc doesn't previosuly exist, create a empty option block. add option 'protocols' for wsc that can specify the optional protocols before the options. Options will also only apply to node client websockets; (package 'ws'), browser websockets only take 1 with 1 optional parameter (being the list of protocols to connect with; so I added that optional param for compatibility.
This commit is contained in:
parent
f548db293b
commit
f28b62fd4c
@ -83,6 +83,7 @@ function Peer (url, options) {
|
||||
this.setMaxListeners(Infinity);
|
||||
|
||||
this.options = options || {};
|
||||
this.options.wsc = options.wsc || { protocols: null };
|
||||
|
||||
// Messages sent before the socket is ready.
|
||||
this.deferredMsgs = [];
|
||||
@ -134,7 +135,7 @@ API.connect = function () {
|
||||
var url = this.url;
|
||||
|
||||
// Open a new websocket.
|
||||
var socket = new WebSocket(url, this.options.wsc);
|
||||
var socket = new WebSocket(url, this.options.wsc.protocols, this.options.wsc);
|
||||
|
||||
// Re-use the previous listeners.
|
||||
socket._events = this._events;
|
||||
|
Loading…
x
Reference in New Issue
Block a user