From acdcd1330f325713d4729d00b895fdc64ab7ad41 Mon Sep 17 00:00:00 2001 From: cubedro Date: Tue, 2 Jun 2015 00:14:28 +0300 Subject: [PATCH] added socket flags --- lib/node.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/node.js b/lib/node.js index 337f497..7438b29 100644 --- a/lib/node.js +++ b/lib/node.js @@ -233,6 +233,7 @@ Node.prototype.setupSockets = function() }) .on('timeout', function () { + self._socket = false; console.error('wsc', 'Socket connection timeout'); }) .on('close', function () @@ -247,6 +248,7 @@ Node.prototype.setupSockets = function() }) .on('online', function () { + self._socket = true; console.info('wsc', 'Network connection is online'); }) .on('reconnect', function () @@ -255,19 +257,23 @@ Node.prototype.setupSockets = function() }) .on('reconnect scheduled', function (opts) { + self._socket = false; console.warn('wsc', 'Reconnecting in', opts.scheduled, 'ms'); console.warn('wsc', 'This is attempt', opts.attempt, 'out of', opts.retries); }) .on('reconnected', function (opts) { + self._socket = true; console.success('wsc', 'Socket reconnected successfully after', opts.duration, 'ms'); }) .on('reconnect timeout', function (err, opts) { + self._socket = false; console.error('wsc', 'Socket reconnect atempt took too long:', err.message); }) .on('reconnect failed', function (err, opts) { + self._socket = false; console.error('wsc', 'Socket reconnect failed:', err.message); }); }