modified to use events, hopefully will fix the crashing particle

This commit is contained in:
Martin Donnelly 2016-02-12 16:28:31 +00:00
parent 3a5cef1262
commit 31ba1ebb94

View File

@ -130,37 +130,21 @@ router.post('/', function (req, res, next) {
//t = JSON.parse(t);
if(t.hasOwnProperty('data')){
logger.debug('We have data');
var data = t.data;
var s = data.toString();
logger.debug(typeof s);
logger.debug(s);
/*dataJSON = JSON.parse(s);
logger.debug(typeof dataJSON);*/
/* if (data.hasOwnProperty(temp)) {
var data = JSON.parse(t.data.toString());
if (data.hasOwnProperty(temp)) {
logger.log('We have temp! ' + data.temp);
}*/
//dataJSON = JSON.parse(data);
//logger.debug(dataJSON);
/* var data = t.data;
dataJSON = JSON.parse(data);
if(dataJSON.hasOwnProperty('temp')) {
busEmitter.emit("saveTempData", {time: now.toJSON(), value: parseFloat(data.temp)});
}
else
{
logger.error('No temp data!');
}*/
}
}
else
{
logger.error('No data block!');
}
/*console.log(JSON.stringify(t));
if (dataJSON != {} && dataJSON.temp != null) {
busEmitter.emit("saveTempData", {time: now.toJSON(), value: parseFloat(dataJSON.temp)});
}*/
res.writeHead(200, {"ContentType": "text/html"});
res.end('ok');