Socket.IO: Push to group of clients

I'm using a Node.js server with Express and want to do the following:

  • clients call an URL with an ID in it (e.g. localhost/show/:projectID)
  • every client calling the same ID should get into the same "group"
  • new messages should be pushed only to the clients in the same "group" but not the clients that called an URL with another ID

How can this be done in Socket.IO? (I have already read about "rooms" but I don't know how to use them together with a URL)

After experimenting a little bit with .handshake I came to a solution similar to that suggested by GeoPhoenix.
I don't know how good my solution is, but it works. Here's the code:

io.sockets.on('connection', function (socket) {
  var ref = JSON.stringify(socket.handshake.headers.referer);
  socket.join(ref);
  io.sockets.in(ref).emit('news', {hello: "world"});
});

As soon as a client connects the URL he used will be saved into ref and he joins a room named after that URL (of course the URL could be processed further to have better room-names, but that's not necessary for the solution to work).