Cleaner topic slection

This commit is contained in:
Nathanaël Lécaudé 2016-05-20 10:45:49 -04:00
parent 6d32edc0f2
commit f6365b0c66

View File

@ -187,33 +187,15 @@ module.exports = function(RED) {
node.duplicates = n.duplicates; node.duplicates = n.duplicates;
function onFound(beacon) { function onFound(beacon) {
var topic_data; node.send({topic: node.topic || 'found', payload: beacon});
if (node.topic !== "") {
topic_data = node.topic;
} else {
topic_data = 'found';
}
node.send({topic: topic_data, payload: beacon});
} }
function onUpdated(beacon) { function onUpdated(beacon) {
var topic_data; node.send({topic: node.topic || 'updated', payload: beacon});
if (node.topic !== "") {
topic_data = node.topic;
} else {
topic_data = 'updated';
}
node.send({topic: topic_data, payload: beacon});
} }
function onLost(beacon) { function onLost(beacon) {
var topic_data; node.send({topic: node.topic || 'lost', payload: beacon});
if (node.topic !== "") {
topic_data = node.topic;
} else {
topic_data = 'lost';
}
node.send({topic: topic_data, payload: beacon});
} }
EddystoneBeaconScanner.on('found', onFound); EddystoneBeaconScanner.on('found', onFound);