Created
January 1, 2013 00:26
-
-
Save jmcguirk/4424144 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
/** | |
* 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