title: php push notification to specific user via nodejs (socket.io) and redis
body: <p>I trying to push notification to specific client with nodejs and redis but emitting the notification to the requested user is not working</p>
  
  <p>my codes in php and nodejs and client is below:</p>
  
  <pre><code>//Nodejs Server ---------------------------
  var io = require('socket.io').listen(3000);
  var redis = require('redis');
  var $clients = {};
  
  var $notifySubscribe = redis.createClient();
  var $loginUserSubscribe = redis.createClient();
  $notifySubscribe.subscribe('notify');
  $loginUserSubscribe.subscribe('loginUser');
  
  $notifySubscribe.on('message', function($channel, $message) {
      var $data = JSON.parse($message);
      if($data.userId in $clients){
          $clients[$data.userId].emit('updateNotifications', '+1');
      }
  });
  
  io.sockets.on('connection', function(socket) {
  
      $loginUserSubscribe.on('message', function($channel, $message){
          var $data = JSON.parse($message);
          if(!($data.userId in $clients)){
              $clients[$data.userId] = socket;
          }
      });
  
  });
  
  //Client ----------------------------------
  socketIo.on('updateNotifications', function($count){
      alert($count);
  });
  
  //Php Server ------------------------------
  $data = array('userId' =&gt; 20584, 'username' =&gt; 'mohammadsaleh');
  $this-&gt;__redis-&gt;publish("notify", json_encode($data));
  </code></pre>