update how recently a domain has been active
This commit is contained in:
parent
0a67728239
commit
c9d6b46f0f
|
@ -14,6 +14,7 @@ Devices.add = function (store, servername, newDevice, isPort) {
|
|||
if (!store._domains) { store._domains = {}; }
|
||||
if (!store._domains[servername]) { store._domains[servername] = []; }
|
||||
store._domains[servername].push(newDevice);
|
||||
Devices.touch(store, servername);
|
||||
|
||||
// add device
|
||||
// TODO only use a device id
|
||||
|
@ -126,7 +127,11 @@ Devices.active = function (store, id) {
|
|||
};
|
||||
*/
|
||||
Devices.exist = function (store, servername) {
|
||||
return !!(Devices.list(store, servername).length);
|
||||
if (Devices.list(store, servername).length) {
|
||||
Devices.touch(store, servername);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
Devices.next = function (store, servername) {
|
||||
var devices = Devices.list(store, servername);
|
||||
|
@ -138,5 +143,14 @@ Devices.next = function (store, servername) {
|
|||
device = devices[devices._index || 0];
|
||||
devices._index = (devices._index || 0) + 1;
|
||||
|
||||
if (device) { Devices.touch(store, servername); }
|
||||
return device;
|
||||
};
|
||||
Devices.touch = function (store, servername) {
|
||||
if (!store._recency) { store._recency = {}; }
|
||||
store._recency[servername] = Date.now();
|
||||
};
|
||||
Devices.lastSeen = function (store, servername) {
|
||||
if (!store._recency) { store._recency = {}; }
|
||||
return store._recency[servername] || 0;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue