index.js
function subscriber(port) {
  var socket = zeromq.socket('sub');
  socket.identity = 'sub' + process.pid;

  // have to subscribe, otherwise nothing would show up
  // subscribe to everything
  socket.subscribe('');

  var totalMessages=0;

  // receive messages
  socket.on('message', function(data) {
    //console.log(socket.identity + ': received data ' + data.toString());
    totalMessages++;
  });

  socket.connect(port); 
  console.log('connected to ' + port);

  // lets count messages recvd
  setInterval(function() {
    console.log('messages received = ' + totalMessages);
    totalMessages=0;
  }, 1000);

}
function subscriber(port) {
  var socket = zeromq.socket('sub');
  socket.identity = 'sub' + process.pid;

  // have to subscribe, otherwise nothing would show up
  // subscribe to everything
  socket.subscribe('');

  var totalMessages=0;

  // receive messages
  socket.on('message', function(data) {
    //console.log(socket.identity + ': received data ' + data.toString());
    totalMessages++;
  });

  socket.connect(port); 
  console.log('connected to ' + port);

  // lets count messages recvd
  setInterval(function() {
    console.log('messages received = ' + totalMessages);
    totalMessages=0;
  }, 1000);

}
function subscriber ( port ) { var socket = zeromq . socket ( 'sub' ) ; socket . identity = 'sub' + process . pid ; // have to subscribe, otherwise nothing would show up // subscribe to everything socket . subscribe ( '' ) ; var totalMessages = 0 ; // receive messages socket . on ( 'message' , function ( data ) { //console.log(socket.identity + ': received data ' + data.toString()); totalMessages ++ ; } ) ; socket . connect ( port ) ; console . log ( 'connected to ' + port ) ; // lets count messages recvd setInterval ( function ( ) { console . log ( 'messages received = ' + totalMessages ) ; totalMessages = 0 ; } , 1000 ) ; }
lets do the subscriber here
lets do the subscriber here