Created
January 21, 2011 23:01
-
-
Save 4z3/790604 to your computer and use it in GitHub Desktop.
Temporary queue up messages
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
// Temporary publish() to queue up messages until connection to Genericore | |
// is ready. | |
var publish_queue = []; | |
var publish_enqueue = function (message) { | |
publish_queue.push(message); | |
log('enqueue: ' + publish_queue.length); | |
}; | |
var publish = publish_enqueue; | |
var ready = function (client) { | |
// bind real publish function and flush publish_queue to Genericore. | |
publish = client.publish; | |
for (var i = 0; i < publish_queue.length; ++i) { | |
log('dequeue: ' + i + '/' + publish_queue.length); | |
publish(publish_queue[i]); | |
}; | |
publish_queue = []; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment