Skip to content

Commit eb74d88

Browse files
committed
Add isConnecting method
1 parent 1746741 commit eb74d88

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

lib/src/main/java/ua/naiksoftware/stomp/client/StompClient.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public class StompClient {
3535
private final ConnectionProvider mConnectionProvider;
3636
private HashMap<String, String> mTopics;
3737
private boolean mConnected;
38+
private boolean isConnecting;
3839

3940
public StompClient(ConnectionProvider connectionProvider) {
4041
mConnectionProvider = connectionProvider;
@@ -82,15 +83,23 @@ public void connect(List<StompHeader> _headers, boolean reconnect) {
8283

8384
case CLOSED:
8485
mConnected = false;
86+
isConnecting = false;
87+
break;
88+
89+
case ERROR:
90+
mConnected = false;
91+
isConnecting = false;
8592
break;
8693
}
8794
});
8895

96+
isConnecting = true;
8997
mMessagesSubscription = mConnectionProvider.messages()
9098
.map(StompMessage::from)
9199
.subscribe(stompMessage -> {
92100
if (stompMessage.getStompCommand().equals(StompCommand.CONNECTED)) {
93101
mConnected = true;
102+
isConnecting = false;
94103
for (ConnectableObservable<Void> observable : mWaitConnectionObservables) {
95104
observable.connect();
96105
}
@@ -203,4 +212,8 @@ private Observable<Void> unsubscribePath(String dest) {
203212
public boolean isConnected() {
204213
return mConnected;
205214
}
215+
216+
public boolean isConnecting() {
217+
return isConnecting;
218+
}
206219
}

0 commit comments

Comments
 (0)