Improve detection of websocket drained status.

Will now work when you lose and regain network. Also removes the
unnecessary InitialMessageRetriever.
This commit is contained in:
Greyson Parrelli
2020-07-21 10:38:42 -04:00
committed by GitHub
parent 96ce42ae91
commit 662f0b8fb6
10 changed files with 106 additions and 266 deletions

View File

@@ -132,8 +132,10 @@ public class SignalServiceMessagePipe {
* {@link Optional#absent()} when an empty response is hit, which indicates the websocket is
* empty.
*
* Important: The empty response will only be hit once for each instance of {@link SignalServiceMessagePipe}.
* That means subsequent calls will block until an envelope is available.
* Important: The empty response will only be hit once for each connection. That means if you get
* an empty response and call readOrEmpty() again on the same instance, you will not get an empty
* response, and instead will block until you get an actual message. This will, however, reset if
* connection breaks (if, for instance, you lose and regain network).
*/
public Optional<SignalServiceEnvelope> readOrEmpty(long timeout, TimeUnit unit, MessagePipeCallback callback)
throws TimeoutException, IOException, InvalidVersionException

View File

@@ -150,6 +150,8 @@ public class WebSocketConnection extends WebSocketListener {
keepAliveSender.shutdown();
keepAliveSender = null;
}
notifyAll();
}
public synchronized WebSocketRequestMessage readRequest(long timeoutMillis)