mafintosh / signalhub

Simple signalling server that can be used to coordinate handshaking with webrtc or other fun stuff.
MIT License
667 stars 97 forks source link

CLI not working #11

Closed hackerkid closed 8 years ago

hackerkid commented 9 years ago

I tried running the CLI but it is not working. The messages are braodcasted but is not received by the subscriber. I am running both of them in localhost.

Also the sample code below is also not producing any results

Server

var SignalServer = require('signalhub/server');
var hub = require('signalhub');

SignalServer().listen(5000, function () {
  console.log("SignalServer listening on 5000");
  var c = hub('peerchat', ['http://localhost:5000']);

  setInterval(function(){
    c.broadcast('new_message', "hey i am here");
  }, 1000);

  c.subscribe('new_client').on('data', function(data){
     console.log("new client!", data.id);
 });
});

Client

var signalhub = require('signalhub'); 
var hub = signalhub('peerchat', ['http://localhost:5000']);

hub.broadcast('new_client',"hey !!!!");
hub.subscribe('new_message').on('data', function(data) {
  console.log('new message', data)
})
mafintosh commented 8 years ago

Should be fixed in the latest version