mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 10:30:38 +00:00
Use improved shutdown for receive command
This commit is contained in:
parent
1058e33f12
commit
5d33f71d4d
4 changed files with 37 additions and 1 deletions
|
@ -255,6 +255,8 @@ public interface Manager extends Closeable {
|
|||
Optional<Duration> timeout, Optional<Integer> maxMessages, ReceiveMessageHandler handler
|
||||
) throws IOException, AlreadyReceivingException;
|
||||
|
||||
void stopReceiveMessages();
|
||||
|
||||
void setReceiveConfig(ReceiveConfig receiveConfig);
|
||||
|
||||
boolean isContactBlocked(RecipientIdentifier.Single recipient);
|
||||
|
|
|
@ -1091,6 +1091,20 @@ public class ManagerImpl implements Manager {
|
|||
receiveMessages(timeout.orElse(Duration.ofMinutes(1)), timeout.isPresent(), maxMessages.orElse(null), handler);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopReceiveMessages() {
|
||||
Thread thread = null;
|
||||
synchronized (messageHandlers) {
|
||||
if (isReceivingSynchronous) {
|
||||
thread = receiveThread;
|
||||
receiveThread = null;
|
||||
}
|
||||
}
|
||||
if (thread != null) {
|
||||
stopReceiveThread(thread);
|
||||
}
|
||||
}
|
||||
|
||||
private void receiveMessages(
|
||||
Duration timeout, boolean returnOnTimeout, Integer maxMessages, ReceiveMessageHandler handler
|
||||
) throws IOException, AlreadyReceivingException {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue