Just FYI, I've seen some issues here and on various other sites about removing event subscriptions with ngSails ($sailsSocket). I'm pretty sure that this has to do with Socket.IO changing some of their method names. For me, at least, making the simple change below gets this functionality working for me using socket.io-client 1.3.7, sails.io.js 0.11.5, and angularSails 0.12.1.
The following block (starting at line 1278 in ngsails.io.js):
//TODO normalize http paths to event names
connection.subscribe = function(event,handler){
var callback = tick($window.io.socket,handler);
$window.io.socket.on(event,callback);
return angular.bind($window.io.socket, $window.io.socket.removeListener, event, callback);
}
Should be updated to:
//TODO normalize http paths to event names
connection.subscribe = function(event,handler){
var callback = tick($window.io.socket,handler);
$window.io.socket.on(event,callback);
return angular.bind($window.io.socket, $window.io.socket.off, event, callback);
}
Then, unsubscribing will work correctly, i.e.:
// Subscribe
var fnUnsubscribe = $sailsSocket.subscribe('event', function(oEvent) { /* Function body */ });
// Unsubscribe
fnUnsubscribe();