Created
June 10, 2011 11:59
-
-
Save guiocavalcanti/1018700 to your computer and use it in GitHub Desktop.
This file contains 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
this.bind('pusher_internal:member_added', function(data){ | |
var timeoutMember = this.members.get(data.user_id); | |
if(timeoutMember && timeoutMember.info.timeoutID){ // The member is present with a timeout | |
clearTimeout(timeoutMember.info.timeoutID); | |
}else{ | |
var member = this.members.add(data.user_id, data.user_info); | |
this.dispatch_with_all('pusher:member_added', member); | |
} | |
}.scopedTo(this)) | |
this.bind('pusher_internal:member_removed', function(data){ | |
var that = this; | |
var member = this.members.remove(data.user_id); // temporally removing | |
member.info.timeoutID = setTimeout(function(){ | |
var member = that.members.remove(data.user_id); | |
if (member) { | |
that.dispatch_with_all('pusher:member_removed', member); | |
} | |
}, 10000); | |
// Adding again with the timeout attribute | |
this.members.add(member.id, member.info); | |
}.scopedTo(this)) | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment