The Node.js Bridge - MrYsLab/xideco GitHub Wiki

The Node.js Bridge is optional and its source is provided below to demonstrate that software written in languages other than Python can easily connect to and communicate with the Xideco network.

The demo bridge provided, listens for all commands being sent to board #1 and prints those commands to the console.

To use this bridge, you will need to install node.js, the ZeroMQ API for node.js and MessagePack for node.js on a computer that already has the base ZeroMQ library installed.

It is assumed that you are familiar with node.js and how to install the necessary packages.

If you would like to try out the bridge, here is the JavaScript code.

// This is a simple JavaScript Xideco Bridge that subscribes to
// Scratch control messages destined for board #1.

var zmq = require('zmq')
  , sock = zmq.socket('sub');

var msgpack = require("msgpack-lite");
var data;

sock.connect('tcp://192.168.2.194:50502');
sock.subscribe('A1');
console.log('Subscriber connected to port 50502');

sock.on('message', function(topic, message) {
  data = msgpack.decode(message);
  console.log('received a message related to:', topic, 'containing message:', data);

});