Reputation:
I have some questions regarding Socket.io and could not find any answer for following terms/functions/whatever of Socket.io. These are used in hundreds of examples to create chat system but none of them has clearly defined what these terms do.
io.sockets.manager
do?io.sockets.join()
do? And another question is that if I have created Rooms array which holds ids of different rooms. Now how can I send message to only particular room? Suppose
var Rooms = [
{ 'a' : 'Room1' },
{ 'b' : 'Room2' },
{ 'c' : 'Room3' }
]
How can I send message to Rooms['a']
only? Like to send msg
to all, it's just:
io.sockets.emit('server_says', { msg: 'Hello All'});
Where can I find some article where all such functions like join()
, manager
etc are found with their details?
Please if possible provide some code so I can understand better.
Upvotes: 1
Views: 2860
Reputation: 5941
I think you have not done your homework. You can find everything about Socket.io at
https://socket.io/get-started/chat/
https://medium.com/@noufel.gouirhate/build-a-simple-chat-app-with-node-js-and-socket-io-ea716c093088
https://www.tutorialspoint.com/socket.io/socket.io_chat_application.htm
https://itnext.io/building-a-node-js-websocket-chat-app-with-socket-io-and-react-473a0686d1e1
These links include answers to all your questions.
Upvotes: 2