Search in sources :

Example 6 with WebSocketUnavailableException

use of org.whispersystems.signalservice.api.websocket.WebSocketUnavailableException in project Signal-Android by WhisperSystems.

the class SignalWebSocket method getWebSocket.

private synchronized WebSocketConnection getWebSocket() throws WebSocketUnavailableException {
    if (!canConnect) {
        throw new WebSocketUnavailableException();
    }
    if (webSocket == null || webSocket.isDead()) {
        webSocketStateDisposable.dispose();
        webSocket = webSocketFactory.createWebSocket();
        webSocketStateDisposable = new CompositeDisposable();
        Disposable state = webSocket.connect().subscribeOn(Schedulers.computation()).observeOn(Schedulers.computation()).subscribe(webSocketState::onNext);
        webSocketStateDisposable.add(state);
    }
    return webSocket;
}
Also used : CompositeDisposable(io.reactivex.rxjava3.disposables.CompositeDisposable) Disposable(io.reactivex.rxjava3.disposables.Disposable) WebSocketUnavailableException(org.whispersystems.signalservice.api.websocket.WebSocketUnavailableException) CompositeDisposable(io.reactivex.rxjava3.disposables.CompositeDisposable)

Aggregations

WebSocketUnavailableException (org.whispersystems.signalservice.api.websocket.WebSocketUnavailableException)6 IOException (java.io.IOException)4 CompositeDisposable (io.reactivex.rxjava3.disposables.CompositeDisposable)2 Disposable (io.reactivex.rxjava3.disposables.Disposable)2 InvalidKeyException (org.whispersystems.libsignal.InvalidKeyException)2 ContentHint (org.whispersystems.signalservice.api.crypto.ContentHint)2 SignalServiceAttachmentPointer (org.whispersystems.signalservice.api.messages.SignalServiceAttachmentPointer)2 SignalServiceAttachmentRemoteId (org.whispersystems.signalservice.api.messages.SignalServiceAttachmentRemoteId)2 AuthorizationFailedException (org.whispersystems.signalservice.api.push.exceptions.AuthorizationFailedException)2 UnregisteredUserException (org.whispersystems.signalservice.api.push.exceptions.UnregisteredUserException)2 MessagingService (org.whispersystems.signalservice.api.services.MessagingService)2 AttachmentV2UploadAttributes (org.whispersystems.signalservice.internal.push.AttachmentV2UploadAttributes)2 AttachmentV3UploadAttributes (org.whispersystems.signalservice.internal.push.AttachmentV3UploadAttributes)2 OutgoingPushMessageList (org.whispersystems.signalservice.internal.push.OutgoingPushMessageList)2 SendMessageResponse (org.whispersystems.signalservice.internal.push.SendMessageResponse)2 GroupMismatchedDevicesException (org.whispersystems.signalservice.internal.push.exceptions.GroupMismatchedDevicesException)2 GroupStaleDevicesException (org.whispersystems.signalservice.internal.push.exceptions.GroupStaleDevicesException)2 InvalidUnidentifiedAccessHeaderException (org.whispersystems.signalservice.internal.push.exceptions.InvalidUnidentifiedAccessHeaderException)2 MismatchedDevicesException (org.whispersystems.signalservice.internal.push.exceptions.MismatchedDevicesException)2 StaleDevicesException (org.whispersystems.signalservice.internal.push.exceptions.StaleDevicesException)2