mirror of
https://github.com/AsamK/signal-cli.git
synced 2026-09-23 06:39:04 +00:00
parent
5d2daedba3
commit
c3bce6730d
@ -20,7 +20,6 @@ import org.whispersystems.signalservice.api.websocket.WebSocketUnavailableExcept
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.time.Instant;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@ -123,7 +122,6 @@ public class ReceiveHelper {
|
|||||||
Manager.ReceiveMessageHandler handler,
|
Manager.ReceiveMessageHandler handler,
|
||||||
final Map<HandleAction, HandleAction> queuedActions
|
final Map<HandleAction, HandleAction> queuedActions
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
final var timeoutInstant = timeout.map(t -> Instant.now().plus(t));
|
|
||||||
int remainingMessages = maxMessages == null ? -1 : maxMessages;
|
int remainingMessages = maxMessages == null ? -1 : maxMessages;
|
||||||
var backOffCounter = 0;
|
var backOffCounter = 0;
|
||||||
isWaitingForMessage = false;
|
isWaitingForMessage = false;
|
||||||
@ -142,8 +140,7 @@ public class ReceiveHelper {
|
|||||||
logger.trace("Checking for new message from server");
|
logger.trace("Checking for new message from server");
|
||||||
try {
|
try {
|
||||||
isWaitingForMessage = true;
|
isWaitingForMessage = true;
|
||||||
final var timeoutMs = timeoutInstant.isPresent() ? Math.min(60_000,
|
final var timeoutMs = timeout.orElseGet(() -> Duration.ofMinutes(1)).toMillis();
|
||||||
Duration.between(Instant.now(), timeoutInstant.get()).toMillis()) : 60_000L;
|
|
||||||
if (timeoutMs <= 0L) {
|
if (timeoutMs <= 0L) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -212,7 +209,7 @@ public class ReceiveHelper {
|
|||||||
throw e;
|
throw e;
|
||||||
} catch (TimeoutException e) {
|
} catch (TimeoutException e) {
|
||||||
backOffCounter = 0;
|
backOffCounter = 0;
|
||||||
if (timeoutInstant.isPresent() && timeoutInstant.get().isBefore(Instant.now())) {
|
if (timeout.isPresent()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user