Comparing version 1.0.2 to 1.0.3
{ | ||
"name": "elws", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Simple auto-reconnect WebSocket decorator", | ||
@@ -5,0 +5,0 @@ "main": "rws.js", |
10
rws.js
@@ -13,6 +13,7 @@ var WebSocket = require('ws'); | ||
this.url = this.urls[this.urlIndex]; | ||
this.times = 1; | ||
this.force = false; | ||
} | ||
RWebSocket.prototype = { | ||
times:1,//retry count | ||
connect: function () { | ||
@@ -45,3 +46,3 @@ var self = this; | ||
// abnormal close | ||
if (!connectTimeout) { | ||
if ((!connectTimeout)&&(!self.force) ){ | ||
connectTimeout = setTimeout(function () { | ||
@@ -71,3 +72,3 @@ if(self.times > self.retryMaxTimes) | ||
case 'ECONNREFUSED': | ||
if (!connectTimeout) { | ||
if ((!connectTimeout)&&(!self.force) ) { | ||
connectTimeout = setTimeout(function () { | ||
@@ -83,3 +84,3 @@ if(self.times > self.retryMaxTimes) | ||
} | ||
//console.log("time out #"+self.times); | ||
// console.log("time out #"+self.times); | ||
self.connect(); | ||
@@ -99,2 +100,3 @@ self.times++; | ||
this.client.stopTimeout = function(){ | ||
self.force = true; | ||
clearTimeout(connectTimeout); | ||
@@ -101,0 +103,0 @@ connectTimeout = null; |
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
6684
102