I'm trying to emit a message from one namespace to another (on connection). Bellow is some sample code with how I was trying to approach it.
[Server]
// Namespaces
var users_ns = io.of('/users');
var machines_ns = io.of('/machines');
// Attempt to receive the event on the socket
users_ns.on('connection', function(socket){
socket.on('test', function(socket){
console.log('socket test');
});
});
// Attempt to receive the event on the namespace
users_ns.on('test', function(socket){
console.log('namespace test');
});
// Emit an event to the 'users' namespace
machines_ns.on('connection', function(socket){
users_ns.emit('test');
});
[Client1]
var socket = io('http://localhost/users');
[Client2]
var socket = io('http://localhost/machines');
Any idea why this doesn't work?