Socket.io rooms - sending and receiving the data
<p>I am not really sure how to send and receive data using socket.io rooms. </p>

<p>This is my client side code:</p>

<pre><code>var socket = io('https://the.url');

socket.on('connect', function() {

    console.log('Connected to the socket.');

});

socket.on("client5", function (data) {

    console.log(data);

});
</code></pre>

<p>And this is my server side code</p>

<pre><code>var app        = require('express')();
var server     = require('http').Server(app);
var https      = require('https');
var fs         = require('fs');
var bodyParser = require('body-parser');

var privateKey  = fs.readFileSync('path/to/key', 'utf8');
var certificate = fs.readFileSync('path/to/key', 'utf8');
var credentials = {key: privateKey, cert: certificate};
var httpsServer = https.createServer(credentials, app);
var io          = require('socket.io')(httpsServer);

// HTTP server listening on port
io.set('origins', '*:*');
io.sockets.on('connection', function (socket) {

});

httpsServer.listen(10000);
// Middle ware
app.use(bodyParser.urlencoded({ extended: true }));

// Route
app.post('/anything', function (req, res) {
    io.emit('client5', req.body);
    res.end();
});
</code></pre>

<p>And this works fine. But this is not using the rooms. This code will just emit data to "client5" socket and on the client side I am able to receive that data using socket.on("client5").</p>

<p>What I want to do is have a group of people that will be joining different rooms.</p>

<p>So user A, B and C will come in and be added to room "First Room" and users D, E and F will be added to "Second Room". </p>

<p>How can I send and receive data between rooms? </p>