1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-25 21:42:07 +01:00

Don't wait the reply timeout in OfflineMessageManager.getMessages(List<String>)

for the last message. We now count the number of messages we want to
retrieve, and don't wait for another message if we have already
received all.

Thanks to King Jeong Hun for reporting this.
This commit is contained in:
Florian Schmaus 2017-01-12 13:40:55 +01:00
parent f31cc6e043
commit b5415fe841

View file

@ -158,12 +158,14 @@ public class OfflineMessageManager {
return nodes.contains(info.getNode()); return nodes.contains(info.getNode());
} }
}); });
int pendingNodes = nodes.size();
StanzaCollector messageCollector = connection.createStanzaCollector(messageFilter); StanzaCollector messageCollector = connection.createStanzaCollector(messageFilter);
try { try {
connection.createStanzaCollectorAndSend(request).nextResultOrThrow(); connection.createStanzaCollectorAndSend(request).nextResultOrThrow();
// Collect the received offline messages // Collect the received offline messages
Message message = messageCollector.nextResult(); Message message = messageCollector.nextResult();
while (message != null) { while (message != null && pendingNodes > 0) {
pendingNodes--;
messages.add(message); messages.add(message);
message = messageCollector.nextResult(); message = messageCollector.nextResult();
} }