Skip to content

Instantly share code, notes, and snippets.

@jmcguirk
Created January 1, 2013 00:26
Show Gist options
  • Save jmcguirk/4424144 to your computer and use it in GitHub Desktop.
Save jmcguirk/4424144 to your computer and use it in GitHub Desktop.
/**
* Prune any inbox items that need to be deleted
*
* @param playerInbox the inbox to prune from
*/
this.pruneReceivedInboxItems = function(playerInbox){
var now = new Date().getTime();
for(var messageId in playerInbox){
var nextMessage = playerInbox[messageId];
var age = now - nextMessage.receivedOn;
if((nextMessage.processed && nextMessage.acked) || (age > ServiceLocator.Constants.PENDING_INBOX_MAX_AGE_MS)){
playerInbox[messageId] = null;
delete(playerInbox[messageId]);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment