XMPPBoshConnection polls too early currently, before it has processed the responses and queued up any new requests for sending. This results in too many messages being sent to the server (e.g. sends poll message, then processes responses, then immediately sends more requests). This can actually result in erroneous behavior – I noticed with Tigase that XIFF was sending the poll when receiving the stream features from Tigase, and Tigase would return with another stream features message, causing 2 separate sessions to eventually be set up.
This patch fixes that by moving the call to pollServer from onRequestComplete to the end of processResponse, so that we can then check to see whether we should poll based on the number of outstanding requests and the length of the request queue.
Comments and feedback welcome, especially acceptance tests against your server deployment.
xmppboshconnection.patch.zip (457 Bytes)