Offline drive (or team) detection
This commit is contained in:
@@ -1835,8 +1835,9 @@ define([
|
||||
//var data = cmdData.data;
|
||||
var s = getStore(cmdData.teamId);
|
||||
if (s.offline) {
|
||||
broadcast([], 'NETWORK_DISCONNECT');
|
||||
return void cb({ error: 'OFFLINE' });
|
||||
var send = s.id ? s.sendEvent : sendDriveEvent;
|
||||
send('NETWORK_DISCONNECT');
|
||||
return void cb({ error: 'OFFLINE' });
|
||||
}
|
||||
var cb2 = function (data2) {
|
||||
// Send the CHANGE event to all the stores because the command may have
|
||||
@@ -2291,17 +2292,18 @@ define([
|
||||
if (path[0] === 'drive' && path[1] === "migrate" && value === 1) {
|
||||
rt.network.disconnect();
|
||||
rt.realtime.abort();
|
||||
broadcast([], 'NETWORK_DISCONNECT');
|
||||
sendDriveEvent('NETWORK_DISCONNECT');
|
||||
}
|
||||
});
|
||||
|
||||
// Proxy handlers (reconnect only called when the proxy is ready)
|
||||
rt.proxy.on('disconnect', function () {
|
||||
store.offline = true;
|
||||
broadcast([], 'NETWORK_DISCONNECT');
|
||||
sendDriveEvent('NETWORK_DISCONNECT');
|
||||
});
|
||||
rt.proxy.on('reconnect', function (info) {
|
||||
rt.proxy.on('reconnect', function () {
|
||||
store.offline = false;
|
||||
broadcast([], 'NETWORK_RECONNECT', {myId: info.myId});
|
||||
sendDriveEvent('NETWORK_RECONNECT');
|
||||
});
|
||||
|
||||
// Ping clients regularly to make sure one tab was not closed without sending a removeClient()
|
||||
|
||||
@@ -57,6 +57,14 @@ define([
|
||||
return false;
|
||||
}
|
||||
});
|
||||
proxy.on('disconnect', function () {
|
||||
team.offline = true;
|
||||
team.sendEvent('NETWORK_DISCONNECT');
|
||||
});
|
||||
proxy.on('reconnect', function () {
|
||||
team.offline = false;
|
||||
team.sendEvent('NETWORK_RECONNECT');
|
||||
});
|
||||
}
|
||||
proxy.on('change', [], function (o, n, p) {
|
||||
if (fId) {
|
||||
@@ -101,12 +109,6 @@ define([
|
||||
path: p
|
||||
});
|
||||
});
|
||||
proxy.on('disconnect', function () {
|
||||
team.offline = true;
|
||||
});
|
||||
proxy.on('reconnect', function (/* info */) {
|
||||
team.offline = false;
|
||||
});
|
||||
};
|
||||
|
||||
var closeTeam = function (ctx, teamId) {
|
||||
@@ -1363,6 +1365,10 @@ define([
|
||||
removeClient(ctx, clientId);
|
||||
};
|
||||
team.execCommand = function (clientId, obj, cb) {
|
||||
if (ctx.store.offline) {
|
||||
return void cb({ error: 'OFFLINE' });
|
||||
}
|
||||
|
||||
var cmd = obj.cmd;
|
||||
var data = obj.data;
|
||||
if (cmd === 'SUBSCRIBE') {
|
||||
|
||||
Reference in New Issue
Block a user