0.1.9 fix initTimeout and retryWait option setting for when zero

master
David Kebler 2020-03-26 13:28:54 -07:00
parent a21aa3bf88
commit 3fb6d99dcc
2 changed files with 10 additions and 7 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@uci/websocket-client", "name": "@uci/websocket-client",
"version": "0.1.8", "version": "0.1.9",
"description": "JSON packet browser client over web socket", "description": "JSON packet browser client over web socket",
"main": "src", "main": "src",
"watch": { "watch": {
@ -34,10 +34,10 @@
"npm-watch": "^0.6.0" "npm-watch": "^0.6.0"
}, },
"dependencies": { "dependencies": {
"auto-bind": "^2.1.0", "auto-bind": "^4.0.0",
"better-try-catch": "^0.6.2", "better-try-catch": "^0.6.2",
"delay": "^4.3.0", "delay": "^4.3.0",
"eventemitter3": "^4.0.0", "eventemitter3": "^4.0.0",
"ws": "^7.1.2" "ws": "^7.2.3"
} }
} }

View File

@ -26,8 +26,8 @@ class WSConsumer extends EventEmitter {
this.name = opts.name || 'browser' this.name = opts.name || 'browser'
this.instanceID = new Date().getTime() this.instanceID = new Date().getTime()
this.url = url this.url = url
this.initTimeout = opts.initTimeout * 1000 || 60000 this.initTimeout = opts.initTimeout!=null ? opts.initTimeout * 1000 : 60000
this.retryWait = opts.retryWait * 1000 || 5000 this.retryWait = opts.retryWait!=null ? opts.retryWait * 1000 : 5000
this.protocol = opts.protocol // available if needed but not documented this.protocol = opts.protocol // available if needed but not documented
this.opts = opts this.opts = opts
this._connected = false this._connected = false
@ -38,6 +38,9 @@ class WSConsumer extends EventEmitter {
autoBind(this) autoBind(this)
} }
// TODO refactor like for tcp socket
// emit connection events
/** /**
* connect - After instantiating this must be called to connect to a UCI WesbSocket Sever * connect - After instantiating this must be called to connect to a UCI WesbSocket Sever
* @required * @required
@ -52,8 +55,8 @@ class WSConsumer extends EventEmitter {
this._conAttempt = 1 this._conAttempt = 1
this.url = opts.url || this.url this.url = opts.url || this.url
this.name = opts.name || this.name this.name = opts.name || this.name
this.initTimeout = opts.initTimeout || this.initTimeout this.initTimeout = opts.initTimeout!=null ? opts.initTimeout * 1000 : this.initTimeout
this.retryWait = opts.retryWait || this.retryWait this.retryWait = opts.retryWait!=null ? opts.retryWait * 1000 : this.retryWait
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {