mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-23 13:45:48 +00:00
Fix network state reporting in server and client.
This commit is contained in:
committed by
Stefan Thomas
parent
54ed214fcf
commit
8196a1e15a
@@ -289,6 +289,7 @@ Remote.prototype._set_state = function (state) {
|
|||||||
this.state = state;
|
this.state = state;
|
||||||
|
|
||||||
this.emit('state', state);
|
this.emit('state', state);
|
||||||
|
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case 'online':
|
case 'online':
|
||||||
this.online_state = 'open';
|
this.online_state = 'open';
|
||||||
@@ -499,7 +500,11 @@ Remote.prototype._connect_message = function (ws, json) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'serverStatus':
|
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;
|
break;
|
||||||
|
|
||||||
// All other messages
|
// All other messages
|
||||||
@@ -861,7 +866,7 @@ Remote.prototype._server_subscribe = function () {
|
|||||||
self.emit('ledger_closed', message);
|
self.emit('ledger_closed', message);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message.server_status === "ok") {
|
if (message.server_status === 'tracking' || message.server_status === 'full') {
|
||||||
self._set_state('online');
|
self._set_state('online');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user