From 50c04492066fdd9ed35c806b4dd61c1b55b2dd53 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Sun, 4 Nov 2018 21:22:07 +0000 Subject: [PATCH] touch device lastSeen on ws pong --- lib/device-tracker.js | 7 +++++++ lib/server.js | 1 + 2 files changed, 8 insertions(+) diff --git a/lib/device-tracker.js b/lib/device-tracker.js index 853c6e2..5c84183 100644 --- a/lib/device-tracker.js +++ b/lib/device-tracker.js @@ -1,6 +1,7 @@ 'use strict'; var Devices = module.exports; +// TODO enumerate store's keys and device's keys for documentation Devices.addPort = function (store, serverport, newDevice) { // TODO make special return Devices.add(store, serverport, newDevice, true); @@ -146,6 +147,12 @@ Devices.next = function (store, servername) { if (device) { Devices.touch(store, servername); } 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) { if (!store._recency) { store._recency = {}; } store._recency[servername] = Date.now(); diff --git a/lib/server.js b/lib/server.js index 59656b0..ef75555 100644 --- a/lib/server.js +++ b/lib/server.js @@ -172,6 +172,7 @@ var Server = { , _initSocketHandlers: function (state, srv) { function refreshTimeout() { srv.lastActivity = Date.now(); + Devices.touchDevice(state.deviceLists, srv); } function checkTimeout() {