Created
March 27, 2017 06:43
-
-
Save akmandev/967f9bfa017421245e1d0c5c1297893e to your computer and use it in GitHub Desktop.
Pusher - Avoiding instant disconnects while navigating/refreshing page
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
function removeMember(member) { | |
pendingRemoves[ member.id ] = setTimeout(function() { | |
removeMemberFromUI(member); | |
}, 3000); // wait 3 seconds | |
}; | |
function addMember(member) { | |
var pendingRemoveTimeout = pendingRemoves[member.id]; | |
if(pendingRemoveTimeout) { | |
// user left, but has rejoined | |
clearTimeout(pendingRemoveTimeout); | |
}else{ | |
// Do normal user add action | |
} | |
// Source: https://support.pusher.com/hc/en-us/articles/202054403-How-can-I-stop-users-going-offline-for-an-instant-when-they-navigate-between-pages- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment