Closed chrispound closed 10 years ago
This is cool. I'm not seeing the log messages come through though.
server or client log messages?
The log
function on the server which broadcasts to the client. It seems to be logging server side but the emit isn't working.
function log(message, socket, room) {
(socket || io).to(room).emit('log', message);
console.log(message);
}
ah i wasn't sure about this one. could we change it to 'io.to(room).emit('log', message)?
Ah is that the problem? That it's only broadcasting to whichever socket it's reacting to? Yeah in most cases we should broadcast to the whole room so maybe where log() is getting called we should just not pass in a specific socket. It may be better to reorder the parameters for that:
function log(message, room, socket) {...}
so that you can call it either like log('hello world!', roomId)
or log('hello world!', roomId, socket)
. We would most commonly use the first one.
Added multiple session/ room support for games and chat using socket.io's rooms. The room id only needs to be on the server right now and we can store it as part of the client's socket.