Skip to content
Browse files

Alert socket disconnetion to all rooms.

  • Loading branch information...
1 parent 9a1c8bd commit 8ce56ee3fe314c49bff644c9332f30754dda2c37 @marcolanaro committed
Showing with 6 additions and 4 deletions.
  1. +6 −4 lib/namespace.js
View
10 lib/namespace.js
@@ -71,7 +71,6 @@ function NameSpace(manager, nameSpace, options) {
if (!sessionOpt || auth(session)) {
var id = socket.id;
- clients[id] = socket;
// not elegant, can be better
var emit2client = function(io_namespace, ids, event, message, room) {
@@ -118,9 +117,12 @@ function NameSpace(manager, nameSpace, options) {
});
socket.on('disconnect', function () {
- delete clients[id];
- for(var i = 0, l = myRoom.length; i < l; i += 1)
- io_namespace.in(myRoom[i]).emit('userLeaved', { room: myRoom[i], user_id: id });
+ for (key in socket.manager.roomClients[id]) {
+ var room = key.replace("/"+nameSpace+"/","").replace("/"+nameSpace,"");
+ if (room !== "") {
+ socket.broadcast.to(room).emit('userLeaved', { room: room, user_id: id});
+ }
+ }
});
}
});

0 comments on commit 8ce56ee

Please sign in to comment.
Something went wrong with that request. Please try again.