Commit c6132148 authored by Leonardo Aramaki's avatar Leonardo Aramaki

Unregister all observers if all reconnection attempts failed

parent e2c0e9b4
...@@ -307,20 +307,21 @@ public class RocketChatWebSocketThread extends HandlerThread { ...@@ -307,20 +307,21 @@ public class RocketChatWebSocketThread extends HandlerThread {
// Needed to use subscriptions because of legacy code. // Needed to use subscriptions because of legacy code.
// TODO: Should update to RxJava 2 // TODO: Should update to RxJava 2
reconnectSubscription.add( reconnectSubscription.add(
connectWithExponentialBackoff() connectWithExponentialBackoff()
.subscribe( .subscribe(
connected -> { connected -> {
if (!connected) { if (!connected) {
connectivityManager.notifyConnecting(hostname); connectivityManager.notifyConnecting(hostname);
} }
reconnectSubscription.clear(); reconnectSubscription.clear();
}, },
err -> { error -> {
logErrorAndUnsubscribe(reconnectSubscription, err); logErrorAndUnsubscribe(reconnectSubscription, error);
connectivityManager.notifyConnectionLost(hostname, connectivityManager.notifyConnectionLost(hostname,
ConnectivityManagerInternal.REASON_NETWORK_ERROR); ConnectivityManagerInternal.REASON_NETWORK_ERROR);
} new Handler(getLooper()).post(this::unregisterListeners);
) }
)
); );
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment