Skip to content

Commit

Permalink
Add isConnecting method
Browse files Browse the repository at this point in the history
  • Loading branch information
NaikSoftware committed Feb 28, 2017
1 parent 1746741 commit eb74d88
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/src/main/java/ua/naiksoftware/stomp/client/StompClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class StompClient {
private final ConnectionProvider mConnectionProvider;
private HashMap<String, String> mTopics;
private boolean mConnected;
private boolean isConnecting;

public StompClient(ConnectionProvider connectionProvider) {
mConnectionProvider = connectionProvider;
Expand Down Expand Up @@ -82,15 +83,23 @@ public void connect(List<StompHeader> _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<Void> observable : mWaitConnectionObservables) {
observable.connect();
}
Expand Down Expand Up @@ -203,4 +212,8 @@ private Observable<Void> unsubscribePath(String dest) {
public boolean isConnected() {
return mConnected;
}

public boolean isConnecting() {
return isConnecting;
}
}

0 comments on commit eb74d88

Please sign in to comment.