added history request/response log

This commit is contained in:
cubedro 2015-04-28 15:47:47 +03:00
parent bf1aed7370
commit 61b5ddd125
1 changed files with 3 additions and 0 deletions

3
app.js
View File

@ -65,6 +65,7 @@ api.on('connection', function(spark) {
if(Nodes.getHistory().requiresUpdate() && !askedForHistory && Nodes.canNodeUpdate(data.id))
{
console.log("asked " + data.id + " for history");
spark.emit('history', Nodes.getHistory().getHistoryRequestInterval());
askedForHistory = true;
}
@ -89,6 +90,7 @@ api.on('connection', function(spark) {
if(Nodes.getHistory().requiresUpdate() && !askedForHistory && Nodes.canNodeUpdate(data.id))
{
console.log("asked " + data.id + " for history");
spark.emit('history', Nodes.getHistory().getHistoryRequestInterval());
askedForHistory = true;
}
@ -96,6 +98,7 @@ api.on('connection', function(spark) {
});
spark.on('history', function(data){
console.log("got history from " + data.id);
client.write({action: 'charts', data: Nodes.addHistory(data.id, data.history)});
askedForHistory = false;
});