I'm starting to develop a chat app for mobile devices and I've decided to use Node.js
plus Socket.IO
to build the main functionality. Basically, what I want to achieve is a private messaging system between users and chat groups that can be created by the users. Everybody can join into a chat room, and those rooms are going to be stored into mongodb
. For creating the rooms in the database, I'm going to use Express
with a simple request with the basic data (room name, description).
I'm pretty new to all the Node.js
/Socket.IO
, so I don't know exactly where do I have to query the database about all the available rooms. What I thought is the following thing:
Express
to get a JSON list of available chat rooms.Get the chat room 'name' or 'id' and use to do the following
io.sockets.on('connection', function (socket, room) {
socket.join(room);
socket.broadcast.to(room).send('Hello room!');
});
I will have to do the connection when the user selects a room, am I right? If so, the room is going to be the token for the connection?