How to create new channel for emit in SAILS.js?
simple
io.sockets.in('ee').emit('messageName', {thisIs: 'theMessage'});
and then in Angular.js
io.socket.on("ee", function(data){
console.log(data);
})
don`t work..
How to create new channel for emit in SAILS.js?
simple
io.sockets.in('ee').emit('messageName', {thisIs: 'theMessage'});
and then in Angular.js
io.socket.on("ee", function(data){
console.log(data);
})
don`t work..
You can use this code, I think it does the work you want but not in the way you mentioned:
In client side before calling the route which we use in server side add these codes:
// Use `io.socket.on()` to listen for the 'hello' event:
io.socket.on('hello', function (data) {
console.log('Socket `' + data.id + '` joined the party!');
});
In your desired route controller add these codes:
// Have the socket which made the request join the "funSockets" room.
sails.sockets.join(req, 'funSockets');
// Broadcast a notification to all the sockets who have joined
// the "funSockets" room, excluding our newly added socket:
sails.sockets.broadcast('funSockets', 'hello', { howdy: 'hi there!'}, req);
Note that this "hi there!" message will not be received by the client which just joined. If you want to send a message to all the clients as well as the new joined one, just remove req parameter from broadcast arguments.
For further information please check this link: http://sailsjs.com/documentation/concepts/realtime