title: Private channels in node.js and redis. How to?
body: <p>I wrote the simple script (app.js) to subscribe redis' channel </p>
  
  <pre><code>var app = require('express').createServer()
  , io = require('socket.io').listen(app);
  
  var redis = require("redis");
  
  app.listen(8080);
  
  ////////////// Dev environment; replace by PERL in production use.
  app.get('/', function (req, res) {
      res.sendfile(__dirname + '/index.html');
  });
  //////////////
  
  io.sockets.on('connection', function (socket) {
      socket.subscribe = redis.createClient();
      socket.subscribe.subscribe('chat');
  
      socket.subscribe.on("message", function(channel, message) {
          socket.send(message);
      });
  
      socket.on('disconnect', function() {
          socket.subscribe.quit();
      });
  
      socket.on('close', function() {
          socket.subscribe.quit();
      });
  });
  </code></pre>
  
  <p>Now, I want to make possible to subscribe to private channel for each user.</p>
  
  <p>I tried to pass extra data via socket.io.connect like this:</p>
  
  <pre><code>&lt;script src="/socket.io/socket.io.js"&gt;&lt;/script&gt;
  &lt;script&gt;
    var socket = io.connect('http://localhost:8080', {'PRIVATE_ROOM_HASH': 'secret_hash'});
    socket.on('message', function (data) {
      console.log(data);
    });
  &lt;/script&gt;
  </code></pre>
  
  <p>and then in app.js</p>
  
  <pre><code>...
  io.sockets.on('connection', function (socket, args) {
      socket.subscribe = redis.createClient();
      socket.subscribe.subscribe(args.PRIVATE_ROOM_HASH);
  
      socket.subscribe.on("message", function(channel, message) {
          socket.send(message);
      });
  </code></pre>
  
  <p>but it does not work.</p>
  
  <p>Any ideas how to resolve private rooms' problem?</p>
  
  <p>Thanks.</p>