node-red-contrib-sacn-in
Advanced tools
Comparing version 0.0.1 to 0.1.0
{ | ||
"name": "node-red-contrib-sacn-in", | ||
"version": "0.0.1", | ||
"version": "0.1.0", | ||
"description": "Streaming ACN Input node for Node-RED", | ||
"main": "index.js", | ||
"main": "none", | ||
"scripts": { | ||
@@ -13,3 +13,3 @@ "test": "echo \"Error: no test specified\" && exit 1" | ||
"nodes": { | ||
"sacn-in": "sacn-in.js" | ||
"sacn_in": "sacn-in.js" | ||
} | ||
@@ -16,0 +16,0 @@ }, |
@@ -0,22 +1,29 @@ | ||
console.log('UNIT'); | ||
module.exports = function(RED){ | ||
var e131 = require('e131'); | ||
function SacnInNode(config){ | ||
var server = new e131.Server(parseInt(config.universe)) | ||
RED.nodes.createNode(this, config); | ||
if(config.universe < 1){ | ||
config.universe = 1; | ||
} | ||
var server = new e131.Server(parseInt(config.universe)) | ||
var node = this; | ||
server.on('packet', (packet)=>{ | ||
const chans = packet.getSlotsData(); | ||
chans.forEach((chan, index) => { | ||
let msg = { | ||
topic: index + 1, | ||
payload: chan | ||
node.on('close', ()=>{ | ||
server._socket.close(); | ||
}) | ||
let timer = null; | ||
server.on('packet', (packet)=>{ | ||
const chans = packet.getSlotsData(); | ||
if(timer == null){ | ||
timer = setTimeout(()=>{ | ||
node.send({payload: chans}); | ||
timer = null; | ||
}, (parseInt(config.interval) || 100)) | ||
} | ||
node.send(msg); | ||
}) | ||
}) | ||
} | ||
RED.nodes.registerType("sacn-in", SacnInNode); | ||
RED.nodes.registerType("sacn_in", SacnInNode); | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2114
26