javascriptnode.jszeromqjzmqvivagraphjs

ZeroMQ (ZMQ) feeding VivaGraph graph on client side


I'm building a HTML page which renders a graph created using VivaGraph ( https://github.com/anvaka/VivaGraphJS ) .

This graph should be fed by data coming from a ZMQ (ZeroMQ) datastream, where my webpage is connected as "Subscriber" to a "Publisher"; the perfect example code is here: https://github.com/zeromq/zeromq.js/#pubsub

The problem is: VivaGraph is for JS on client side while ZMQ is for NodeJS environment.

How can bind my VivaGraph graph to the ZMQ data stream in the client side?


Solution

  • You could look into libraries like JSMQ or zwssock that implement ZMQ over websockets, however these seem harder to use.

    I would go the easy way and place a simple express http server in the middle. Html client sends periodical get requests to the express server, server connects to ZMQ and fetches the data and sends it back to the client as json.

    Alternatively, you could also do a websockets connection between the html client and the server, while the server also maintains a connection to ZMQ and pipes data to the websockets.