# HG changeset patch # User Drew Perttula # Date 1465816327 0 # Node ID 31612b323436111c1b5e2eb87bfef1025876de94 # Parent df6bfc7e55849d836245f723d56e2d47255a2332 pass packet creation time so collector can see how much lag there is Ignore-this: aa3fae53817ad8f617822a558f2ae19e diff -r df6bfc7e5584 -r 31612b323436 bin/collector --- a/bin/collector Mon Jun 13 08:39:36 2016 +0000 +++ b/bin/collector Mon Jun 13 11:12:07 2016 +0000 @@ -35,7 +35,8 @@ settings.append((URIRef(device), URIRef(attr), Literal(value))) self.collector.setAttrs(body['client'], body['clientSession'], - settings) + settings, + body['sendTime']) request.setResponseCode(202) @app.route('/stats', methods=['GET']) diff -r df6bfc7e5584 -r 31612b323436 light9/collector/collector.py --- a/light9/collector/collector.py Mon Jun 13 08:39:36 2016 +0000 +++ b/light9/collector/collector.py Mon Jun 13 11:12:07 2016 +0000 @@ -72,7 +72,7 @@ out[(d, da)] = v return out - def setAttrs(self, client, clientSession, settings): + def setAttrs(self, client, clientSession, settings, sendTime): """ settings is a list of (device, attr, value). These attrs are device attrs. We resolve conflicting values, process them into @@ -82,6 +82,7 @@ Call with settings=[] to ping us that your session isn't dead. """ now = time.time() + print now - sendTime self._forgetStaleClients(now) diff -r df6bfc7e5584 -r 31612b323436 light9/web/light9-collector-client.html --- a/light9/web/light9-collector-client.html Mon Jun 13 08:39:36 2016 +0000 +++ b/light9/web/light9-collector-client.html Mon Jun 13 11:12:07 2016 +0000 @@ -36,7 +36,9 @@ this.$.put.body = JSON.stringify({ "settings": settings, "client": window.location.href, - "clientSession": this.clientSession}); + "clientSession": this.clientSession, + "sendTime": Date.now() / 1000 + }); this.$.put.generateRequest(); this.lastSent = settings.slice(); }