From eb74d8813ba72524442e8e6f8e9d3558dab7da6b Mon Sep 17 00:00:00 2001 From: NaikSoftware Date: Tue, 28 Feb 2017 19:23:11 +0200 Subject: [PATCH] Add isConnecting method --- .../ua/naiksoftware/stomp/client/StompClient.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/src/main/java/ua/naiksoftware/stomp/client/StompClient.java b/lib/src/main/java/ua/naiksoftware/stomp/client/StompClient.java index 9973ccb..bf24449 100644 --- a/lib/src/main/java/ua/naiksoftware/stomp/client/StompClient.java +++ b/lib/src/main/java/ua/naiksoftware/stomp/client/StompClient.java @@ -35,6 +35,7 @@ public class StompClient { private final ConnectionProvider mConnectionProvider; private HashMap mTopics; private boolean mConnected; + private boolean isConnecting; public StompClient(ConnectionProvider connectionProvider) { mConnectionProvider = connectionProvider; @@ -82,15 +83,23 @@ public void connect(List _headers, boolean reconnect) { case CLOSED: mConnected = false; + isConnecting = false; + break; + + case ERROR: + mConnected = false; + isConnecting = false; break; } }); + isConnecting = true; mMessagesSubscription = mConnectionProvider.messages() .map(StompMessage::from) .subscribe(stompMessage -> { if (stompMessage.getStompCommand().equals(StompCommand.CONNECTED)) { mConnected = true; + isConnecting = false; for (ConnectableObservable observable : mWaitConnectionObservables) { observable.connect(); } @@ -203,4 +212,8 @@ private Observable unsubscribePath(String dest) { public boolean isConnected() { return mConnected; } + + public boolean isConnecting() { + return isConnecting; + } }