changeset 1489:31612b323436

pass packet creation time so collector can see how much lag there is Ignore-this: aa3fae53817ad8f617822a558f2ae19e
author Drew Perttula <drewp@bigasterisk.com>
date Mon, 13 Jun 2016 11:12:07 +0000
parents df6bfc7e5584
children 649d482737e0
files bin/collector light9/collector/collector.py light9/web/light9-collector-client.html
diffstat 3 files changed, 7 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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'])
--- 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)
 
--- 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();
        }