Split receiveMessages method

This commit is contained in:
AsamK 2021-10-21 21:19:14 +02:00
parent 430c155f7e
commit 5c389c875d
6 changed files with 32 additions and 15 deletions

View file

@ -193,9 +193,15 @@ public interface Manager extends Closeable {
void requestAllSyncData() throws IOException;
void receiveMessages(
long timeout, TimeUnit unit, boolean returnOnTimeout, ReceiveMessageHandler handler
) throws IOException;
/**
* Receive new messages from server, returns if no new message arrive in a timespan of timeout.
*/
void receiveMessages(long timeout, TimeUnit unit, ReceiveMessageHandler handler) throws IOException;
/**
* Receive new messages from server, returns only if the thread is interrupted.
*/
void receiveMessages(ReceiveMessageHandler handler) throws IOException;
void setIgnoreAttachments(boolean ignoreAttachments);

View file

@ -873,7 +873,16 @@ public class ManagerImpl implements Manager {
}
@Override
public void receiveMessages(
public void receiveMessages(long timeout, TimeUnit unit, ReceiveMessageHandler handler) throws IOException {
receiveMessages(timeout, unit, true, handler);
}
@Override
public void receiveMessages(ReceiveMessageHandler handler) throws IOException {
receiveMessages(1L, TimeUnit.HOURS, false, handler);
}
private void receiveMessages(
long timeout, TimeUnit unit, boolean returnOnTimeout, ReceiveMessageHandler handler
) throws IOException {
retryFailedReceivedMessages(handler);