| 40 | |
| 41 | // Attempt to send the event to the socket. If socket no longer exists, remove it from set |
| 42 | function sendToMultiple(send, msg, destinations, type) { |
| 43 | destinations = destinations instanceof Array && destinations || [destinations]; |
| 44 | destinations.forEach(function(destination) { |
| 45 | var set, socketIds; |
| 46 | set = subscriptions[type]; |
| 47 | if ((socketIds = set.members(destination))) { |
| 48 | return socketIds.slice(0).forEach(function(socketId) { |
| 49 | if (!send.socketId(socketId, msg, destination)) { |
| 50 | return set.removeFromAll(socketId); |
| 51 | } |
| 52 | }); |
| 53 | } |
| 54 | }); |
| 55 | return true; |
| 56 | } |