This is Mozilla XPCOM bindings for 0MQ (2.2.x recommended).
Debian or Ubuntu Required Packages cmake / xulrunner-dev / libzmq
- cmake .
- make
brew install cmake pkg-config .
- build zeromq 2.2.x.
- download and untar xulrunner-sdk.
- cmake -D XULRUNNER-SDK=/usr/local/xulrunner-sdk .
- make
Copy built .so and .xpt to your xulrunner application's components directory.
// create new zmq context
var zmqContext = Components.classes["@racklin.gmail.com/zmq;1"].createInstance(Components.interfaces.nsIZMQ);
// dump zmq version
// alert or console.log
alert(zmqContext.version);
// init zmq context with io threads number
zmqContext.init(1);
// create socket with type
zmqContext.socket(zmqContext.ZMQ_REQ);
// connect to endpoint
zmqContext.connect("tcp://127.0.0.1:5555");
// send
zmqContext.send("hello world.");
// recv
var message = zmqContext.recv();
// close socket
zmqContext.close();
// terminate context
zmqContext.term();
Licensed under the LGPL License.