added optional poll delay to amq.js

git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@416640 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gregory John Wilkins 2006-06-23 08:53:23 +00:00
parent 6a794d8a60
commit 990b852b42
1 changed files with 13 additions and 2 deletions

View File

@ -13,6 +13,10 @@ var amq =
// Polling. Set to true (default) if waiting poll for messages is needed // Polling. Set to true (default) if waiting poll for messages is needed
poll: true, poll: true,
// Poll delay. if set to positive integer, this is the time to wait in ms before
// sending the next poll after the last completes.
_pollDelay: 0,
_first: true, _first: true,
_pollEvent: function(first) {}, _pollEvent: function(first) {},
_handlers: new Array(), _handlers: new Array(),
@ -96,8 +100,15 @@ var amq =
} }
amq.endBatch(); amq.endBatch();
new Ajax.Request(amq.uri, { method: 'get', onSuccess: amq._pollHandler }); if (amq._pollDelay>0)
setTimeout('amq._sendPoll()',amq._pollDelay);
else
amq._sendPoll();
},
_sendPoll: function(request)
{
new Ajax.Request(amq.uri, { method: 'get', onSuccess: amq._pollHandler });
}, },
// Add a function that gets called on every poll response, after all received // Add a function that gets called on every poll response, after all received