Created
September 1, 2010 18:56
-
-
Save 3rd-Eden/561160 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// instead of using .broadcast we are looping of the clients to see if they are in the correct channel | |
broadcast = function( response ){ | |
var clientList = client.listener.clients, | |
length = clientList.length, i; | |
for( i = 0; i < length; i++ ){ | |
if( clientList[i] && ( clientList[i].sessionId && clientList[i].sessionId !== sessionId && clientList[i] !== client ) && clientList[i].channel && clientList[i].channel == client.channel ){ | |
clientList[i].send( response ); | |
} | |
} | |
}, | |
// get the first availble client, as it will be marked as tracker | |
firstAvailable = function( response ){ | |
var clientList = client.listener.clients, | |
length = clientList.length, i; | |
for( i = 0; i < length; i++ ){ | |
if( clientList[i] && ( clientList[i].sessionId && clientList[i].sessionId !== sessionId && clientList[i] !== client ) && clientList[i].channel && clientList[i].channel == client.channel ){ | |
clientList[i].send( response ); | |
return; | |
} | |
} | |
}, | |
// continue to only broadcast to this user | |
bySessionId = function( response, sess ){ | |
var clientList = client.listener.clients, | |
length = clientList.length, i; | |
for( i = 0; i < length; i++ ){ | |
if( clientList[i] && ( clientList[i].sessionId && clientList[i].sessionId == sess ) && clientList[i] !== client ){ | |
clientList[i].send( response ); | |
return; | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment