From 8196a1e15a266e4a53ab8d48dd43146806076212 Mon Sep 17 00:00:00 2001 From: Arthur Britto Date: Fri, 14 Dec 2012 16:34:11 -0800 Subject: [PATCH] Fix network state reporting in server and client. --- src/js/remote.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/js/remote.js b/src/js/remote.js index 4a84228d..968b6028 100644 --- a/src/js/remote.js +++ b/src/js/remote.js @@ -289,6 +289,7 @@ Remote.prototype._set_state = function (state) { this.state = state; this.emit('state', state); + switch (state) { case 'online': this.online_state = 'open'; @@ -499,7 +500,11 @@ Remote.prototype._connect_message = function (ws, json) { break; case 'serverStatus': - this._set_state(message.server_status === 'ok' ? 'online' : 'offline'); + // This message is only received when online. As we are connected, it is the definative final state. + this._set_state( + message.server_status === 'tracking' || message.server_status === 'full' + ? 'online' + : 'offline'); break; // All other messages @@ -861,7 +866,7 @@ Remote.prototype._server_subscribe = function () { self.emit('ledger_closed', message); } - if (message.server_status === "ok") { + if (message.server_status === 'tracking' || message.server_status === 'full') { self._set_state('online'); }