touch device lastSeen on ws pong

This commit is contained in:
AJ ONeal 2018-11-04 21:22:07 +00:00
parent d48707d265
commit 50c0449206
2 changed files with 8 additions and 0 deletions

View File

@ -1,6 +1,7 @@
'use strict'; 'use strict';
var Devices = module.exports; var Devices = module.exports;
// TODO enumerate store's keys and device's keys for documentation
Devices.addPort = function (store, serverport, newDevice) { Devices.addPort = function (store, serverport, newDevice) {
// TODO make special // TODO make special
return Devices.add(store, serverport, newDevice, true); return Devices.add(store, serverport, newDevice, true);
@ -146,6 +147,12 @@ Devices.next = function (store, servername) {
if (device) { Devices.touch(store, servername); } if (device) { Devices.touch(store, servername); }
return device; return device;
}; };
Devices.touchDevice = function (store, device) {
// TODO use device.id (which will be pubkey thumbprint) and store._devices[id].domainsMap
Object.keys(device.domainsMap).forEach(function (servername) {
Devices.touch(store, servername);
});
};
Devices.touch = function (store, servername) { Devices.touch = function (store, servername) {
if (!store._recency) { store._recency = {}; } if (!store._recency) { store._recency = {}; }
store._recency[servername] = Date.now(); store._recency[servername] = Date.now();

View File

@ -172,6 +172,7 @@ var Server = {
, _initSocketHandlers: function (state, srv) { , _initSocketHandlers: function (state, srv) {
function refreshTimeout() { function refreshTimeout() {
srv.lastActivity = Date.now(); srv.lastActivity = Date.now();
Devices.touchDevice(state.deviceLists, srv);
} }
function checkTimeout() { function checkTimeout() {