Index: jive/share/jive/net/Comet.lua =================================================================== --- jive/share/jive/net/Comet.lua (revision 1812) +++ jive/share/jive/net/Comet.lua (working copy) @@ -336,6 +336,36 @@ end +-- Send all un-acknowledged or pending subscriptions and requests +function _sendOutstandingRequests(self) + local data = {} + + -- Add any un-acknowledged requests to the outgoing data + for i, v in ipairs(self.sent_reqs) do + table.insert(data, v) + end + + -- Add any other pending requests to the outgoing data + _addPendingRequests(self, data) + + -- Only continue if we have some data to send + if data[1] then + if log:isDebug() then + log:debug("Sending unack/pending request(s):") + debug.dump(data, 5) + end + + local req = CometRequest( + _getRequestSink(self), + self.uri, + data + ) + + self.rhttp:fetch(req) + end +end + + function subscribe(self, subscription, func, playerid, request, priority) local id = self.reqid @@ -630,19 +660,6 @@ subscription = '/' .. self.clientId .. '/**', } } - -- Add any un-acknowledged requests to the outgoing data - for i, v in ipairs(self.sent_reqs) do - table.insert(data, v) - end - - -- Add any other pending requests to the outgoing data - _addPendingRequests(self, data) - - if log:isDebug() then - log:debug("Sending pending request(s):") - debug.dump(data, 5) - end - -- This will be our last request on this connection, it is now only -- for listening for responses @@ -773,8 +790,8 @@ if event.successful then _state(self, CONNECTED) - -- send any requests queued during connect - _sendPendingRequests(self) + -- send any unack/pending requests + _sendOutstandingRequests(self) else return _handleAdvice(self) end