Answer the question
In order to leave comments, you need to log in
Room socket.io?
Just started to study work with sockets, it's not clear yet.
The following picture is drawn in my head:
Server:
var io = require( 'socket.io' )( http );
io.sockets.on( 'connection', function( socket ) {
socket.to( 'room_1' ).emit( 'msg', 'text' );
} );
var socket = io( 'http://examle.loc/' );
socket.on( 'msg', function( msg ) {
console.log( msg );
} );
Answer the question
In order to leave comments, you need to log in
It will be displayed as soon as you send it to the client, or to all clients.
You send a message to room_1, but no one enters it.
To get it, the client needs to join in the right room.
Or do emit/broadcast,
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question