Comparing version 0.26.2 to 0.26.3
@@ -88,4 +88,10 @@ // Generated by LiveScript 1.5.0 | ||
WebSocketConnector.prototype.connect = function(){ | ||
this.startConnectTime = Date.now(); | ||
this.logConnectErrorDelay = 1000; | ||
this.shouldReconnectOnSocketClosed = true; | ||
this.shouldUseInternalReconnect = true; | ||
return this._internalConnect(); | ||
}; | ||
WebSocketConnector.prototype._internalConnect = function(){ | ||
var x$; | ||
this.shouldReconnectOnSocketClosed = true; | ||
x$ = this.socket = new WebSocket("ws://" + this.exocomHost + ":" + this.exocomPort + "/services"); | ||
@@ -99,8 +105,14 @@ x$.on('open', this._onSocketOpen); | ||
WebSocketConnector.prototype._onSocketClose = function(){ | ||
this.emit('offline'); | ||
if (this.shouldReconnectOnSocketClosed) { | ||
return this.connect(); | ||
if (this.shouldUseInternalReconnect) { | ||
return this._internalConnect(); | ||
} else { | ||
return this.connect(); | ||
} | ||
} else { | ||
return this.emit('offline'); | ||
} | ||
}; | ||
WebSocketConnector.prototype._onSocketOpen = function(){ | ||
this.shouldUseInternalReconnect = false; | ||
return this.emit('online'); | ||
@@ -112,2 +124,8 @@ }; | ||
return this.emit('error', "port " + this.exocomPort + " is already in use"); | ||
case this.socket.readyState !== WebSocket.CONNECTING: | ||
if (Date.now() > this.startConnectTime + this.logConnectErrorDelay) { | ||
this.emit('error', "Could not connect after " + this.logConnectErrorDelay + "ms: " + error.message); | ||
return this.logConnectErrorDelay = this.logConnectErrorDelay * 2; | ||
} | ||
break; | ||
default: | ||
@@ -114,0 +132,0 @@ return this.emit('error', error); |
{ | ||
"name": "exorelay", | ||
"version": "0.26.2", | ||
"version": "0.26.3", | ||
"author": "Kevin Goslar", | ||
@@ -5,0 +5,0 @@ "dependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
23690
486