Created
July 9, 2013 00:03
-
-
Save Esya/5953544 to your computer and use it in GitHub Desktop.
Recursive client disconnection for socket.io tests.
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 having.. | |
client.disconnect(); | |
client2.disconnect(); | |
client3.disconnect(); | |
done(); | |
//Top of file | |
function recursiveDisconnect(Clients, callback) { | |
Client = Clients.pop(); | |
Client.on('disconnect',function() { | |
if(Clients.length > 0) recursiveDisconnect(Clients); | |
else { | |
callback(); | |
} | |
}); | |
Client.disconnect(); | |
} | |
//In test | |
recursiveDisconnect([client,client2,client3],done); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment