How to build a chatroom which new channels can be created during server running?

Problem

Having read posts about node.js for a long time, I tried to write my own style of chatroom with socket.io . Here's the link, but only one channel: http://zhonglichat.cnodejs.net/ Here's what I'm thinking about: Visitors can create new channels by typing title and clicking 'Submit'. Then they can also visit the new channel just like visiting another chatroom. And all these happen while the server is running. I went through the guide on socket.io , seems it's hard to create new channels. So is there any simple way via which I can make that?

Problem courtesy of: jiyinyiyong

Solution

There's no need to create a channel with the latest version of Socket.IO, the important thing is just to make clients join it, look at this code example on the server side (from the github repo):

var io = require('socket.io').listen(80);

io.sockets.on('connection', function (socket) {
  socket.join('justin bieber fans');
  socket.broadcast.to('justin bieber fans').emit('new fan');
  io.sockets.in('rammstein fans').emit('new non-fan');
});

As you can see the 'justin bieber fans' channel wasn't created, but clients can join it.

Solution courtesy of: alessioalex

Discussion

There is currently no discussion for this recipe.

This recipe can be found in it's original form on Stack Over Flow.