Haiku HaikuHelper + Node.js

snx

Member
How would you suggest integrating HH and Node.js?  The JSON API?
 
I've been playing around with creating a simple TCP server running on Node.js in order to provide feedback from an HAI panel to an RTI XP-6 controller.  RTI does make a driver for HAI, however it's buggy and unreliable (the driver tends to hang while retrieving certain types of information from the HAI panel).  Until they update the driver, I've been using limited 1-way control over a global cache RS-232 port.  RTI does make a simple 2-way "strings" driver that can send/receive simple ascii strings over tcp so why not have Node.js be the glue between HH and the RTI system.  Something like:
 
RTI Controller sends ascii "U1" - Node.js TCP server receives string / queries HH JSON object / Sends back ascii "ON" to RTI - The RTI controller now updates a flag and any connected remotes know unit 1 is actually on.
 
Moving forward, I could see even keeping some states in Node.js too rather than querying each request.  What do you think?  
 
Yes the JSON API would be very natural for Node. HaikuHelper is designed for this. Keep in mind that HaikuHelper has a built in JavaScript environment very similar to Node.js which you could potentially use to do this without Node.js -- just something to consider.
 
Well that would save a lot of time. Reading through the API documents, I now see the open socket method. Is that what you are referring to?
 
Can HaikuHelper listen for incoming connections or just make outgoing?  The following does not open a port:
 
Code:
var socket = helper.openSocket(controller, '127.0.0.1', 8888);

function onSocketBytesAvailable(socket) {
   var msg = socket.read()
   helper.logToExternalFile('Socket.log', "Message: " + msg);
   socket.close();
}
 
That's outgoing only. Keep in mind you can call your own Functions via the HTTP API. What are you trying to achieve?
 
Ideally, have HH listen for incoming connections and respond to simple ascii messages.  The best I can do on the RTI side is connect to a TCP port and send/receive simple ascii strings.  It's more or less a fallback driver for cases where RTI or a 3rd party hasn't developed a full blown 2-way communications driver.  The best example would be RS-232 or TCP/IP control of a receiver where you send a command and receive a response.
 
Of course most A/V components don't implement any kind of authentication (nor does the RTI driver) so this may be impossible without something like node.js in the middle regardless.
 
Back
Top