Search in sources :

Example 1 with OnErrorNotImplementedException

use of io.reactivex.exceptions.OnErrorNotImplementedException in project Rocket.Chat.Android by RocketChat.

the class RxWebSocket method connect.

public ConnectableFlowable<RxWebSocketCallback.Base> connect(String url) {
    final Request request = new Request.Builder().url(url).build();
    return Flowable.create((FlowableOnSubscribe<RxWebSocketCallback.Base>) emitter -> httpClient.newWebSocket(request, new WebSocketListener() {

        @Override
        public void onOpen(WebSocket webSocket, Response response) {
            RxWebSocket.this.webSocket = webSocket;
            emitter.onNext(new RxWebSocketCallback.Open(RxWebSocket.this.webSocket, response));
        }

        @Override
        public void onFailure(WebSocket webSocket, Throwable err, Response response) {
            try {
                emitter.onError(new RxWebSocketCallback.Failure(webSocket, err, response));
            } catch (OnErrorNotImplementedException ex) {
                RCLog.w(ex, "OnErrorNotImplementedException ignored");
            }
        }

        @Override
        public void onMessage(WebSocket webSocket, String text) {
            emitter.onNext(new RxWebSocketCallback.Message(webSocket, text));
        }

        @Override
        public void onClosed(WebSocket webSocket, int code, String reason) {
            emitter.onNext(new RxWebSocketCallback.Close(webSocket, code, reason));
            emitter.onComplete();
        }
    }), BackpressureStrategy.BUFFER).publish();
}
Also used : FlowableOnSubscribe(io.reactivex.FlowableOnSubscribe) WebSocketListener(okhttp3.WebSocketListener) Request(okhttp3.Request) OnErrorNotImplementedException(io.reactivex.exceptions.OnErrorNotImplementedException) WebSocket(okhttp3.WebSocket) Response(okhttp3.Response)

Example 2 with OnErrorNotImplementedException

use of io.reactivex.exceptions.OnErrorNotImplementedException in project RxJava by ReactiveX.

the class EmptyCompletableObserver method onError.

@Override
public void onError(Throwable e) {
    lazySet(DisposableHelper.DISPOSED);
    RxJavaPlugins.onError(new OnErrorNotImplementedException(e));
}
Also used : OnErrorNotImplementedException(io.reactivex.exceptions.OnErrorNotImplementedException)

Aggregations

OnErrorNotImplementedException (io.reactivex.exceptions.OnErrorNotImplementedException)2 FlowableOnSubscribe (io.reactivex.FlowableOnSubscribe)1 Request (okhttp3.Request)1 Response (okhttp3.Response)1 WebSocket (okhttp3.WebSocket)1 WebSocketListener (okhttp3.WebSocketListener)1