My app is about web conference using webrtc. When clients are conferencing and chatting, everything about emitting and receiving events with socket.io works fine. Now i want to inform main page viewers about the current number of rooms and clients, so i added socket to this page too
main page
var socket = io.connect('https://...................');
socket.on('connect', function() {
console.log('check 2', socket.connected);
socket.emit('check','hello'); // works fine
});
socket.on('numbers',function(data){
console.log(JSON.stringify(data)); // nothing as output
});
socket.on('error', function (err) {
console.log(err);
});
Now, if a client disconnects, server catches disconnection event but no emit takes place
server
io.on('connection' , function(socket){
.........
socket.on('disconnecting', function(){
socket.broadcast.emit('numbers','hello');
});
});
I cannot figure out what the problem is. Is it that main page viewers are not in the same socket as clients in a room; I think i'm missing something important here. Thanks in advance