title: getting data from browser with socket.on method on node.js
body: <p>With nodejs I'm streaming data to client/browser and listing them without any problem. What I wanted to do was sending back some of the ids to the server by clicking on them. Anyway here is my code. I hope you would tell what I'm doing wrong in this case.</p>
  
  <p><strong>Server Side</strong></p>
  
  <pre><code>var socketServer = io.listen(server);
  socketServer.set('log level', 1); //don't log all emits etc
  
  socketServer.sockets.on('connection', function(socket) {
      console.log('New connection logged');
      socketServer.sockets.emit('data', t.globalState);
  });
  
  //This is not working!
  //I tried to put it in different places, no changes!
  socketServer.sockets.on('hello', function(data) {
      console.log('Hello!');
  }); 
  
  socketServer.sockets.on('close', function(socket) {
      console.log('socketServer has closed');
  });
  
  var t = new conwit(config.conwit);
  
  t.openStream = function () {
      console.log('Opening Stream');
      t.createStream();
  };
  t.createStream = function () {
  
      t.stream('statuses/filter', {
          track: t.globalState.tags,
          language: config.language
      }, function(stream) {
  
                  stream.on('data', t.emitT);
                  stream.on('error', function(error) {
                      console.log("My error: ", error);
                      setTimeout(function () {
                          t.openStream();
                      }, 30000);
  
                  });
  
      });
  
  };
  
  t.emitT = function (data) {
          console.log(' receiving');
          if (data.text !== undefined) {
              socketServer.sockets.emit('data', data);
          }
  };
  
  t.openStream();
  
  return t;
  
  };
  </code></pre>
  
  <p><strong>Browser Side</strong></p>
  
  <pre><code>TM.socket.on('data', function(msg) {
     alert('News from server: ' + msg); //this works
     TM.socket.emit('hello', {msg:'Hello server'}); //this doesn't work!
  });
  
  $('#send').on('click', function(event) {
      event.preventDefault();
      TM.socket.emit('hello', { //this doesn't work
          rF: "foo",
          rT: "zazz",
          ea: "limk"
      });
  });
  </code></pre>
  
  <p>There is no error/log messages on both sides. </p>