Created
April 24, 2011 23:28
-
-
Save aashay/939974 to your computer and use it in GitHub Desktop.
NowJS ClientGroup .on "bug"
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
24 Apr 16:27:32 - Client 8192318114452064 connected | |
Adding 8192318114452064. Counter is 0 | |
24 Apr 16:27:39 - Initializing client with transport "websocket" | |
24 Apr 16:27:39 - Client 4147976329550147 connected | |
Adding 4147976329550147. Counter is 1 | |
Adding 4147976329550147. Counter is 2 | |
24 Apr 16:27:53 - Initializing client with transport "websocket" | |
24 Apr 16:27:53 - Client 015604767017066479 connected | |
Adding 015604767017066479. Counter is 3 | |
Adding 015604767017066479. Counter is 4 | |
Adding 015604767017066479. Counter is 5 |
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
var counter = 0; | |
everyone.now.doGroupTest = function(){ | |
var group = nowjs.getGroup("FOO"); | |
group.on('connect', function(){ | |
console.log("Adding " + this.user.clientId + ". Counter is " + counter); | |
counter++; | |
}); | |
group.addUser(this.user.clientId); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Steps to reproduce:
Rather than incrementing the counter one time (so that counter is 3), it increments every time PER connection. There are only three clients connected but the "connect" event is fired a lot more than it should be.