Skip to content

Commit f948c53

Browse files
Merge remote-tracking branch 'NaikSoftware/master' into NoJack
# Conflicts: # example-client/build.gradle # example-client/src/main/java/ua/naiksoftware/stompclientexample/MainActivity.java # lib/build.gradle # lib/src/main/java/ua/naiksoftware/stomp/ConnectionProvider.java # lib/src/main/java/ua/naiksoftware/stomp/OkHttpConnectionProvider.java # lib/src/main/java/ua/naiksoftware/stomp/WebSocketsConnectionProvider.java # lib/src/main/java/ua/naiksoftware/stomp/client/StompClient.java
2 parents 3880e3c + b55536b commit f948c53

File tree

5 files changed

+15
-10
lines changed

5 files changed

+15
-10
lines changed

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
package ua.naiksoftware.stompclientexample;
22

3+
import io.reactivex.Flowable;
34
import retrofit2.http.POST;
45
import retrofit2.http.Query;
5-
import rx.Observable;
66

77
/**
88
* Created by Naik on 24.02.17.
99
*/
1010
public interface ExampleRepository {
1111

1212
@POST("hello-convert-and-send")
13-
Observable<Void> sendRestEcho(@Query("msg") String message);
13+
Flowable<Void> sendRestEcho(@Query("msg") String message);
1414
}

example-client/src/main/java/ua/naiksoftware/stompclientexample/RestClient.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package ua.naiksoftware.stompclientexample;
22

33
import retrofit2.Retrofit;
4-
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
4+
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
55
import retrofit2.converter.gson.GsonConverterFactory;
66

77
/**
@@ -33,7 +33,7 @@ public static RestClient getInstance() {
3333
private RestClient() {
3434
Retrofit retrofit = new Retrofit.Builder().baseUrl("http://" + ANDROID_EMULATOR_LOCALHOST + ":" + SERVER_PORT + "/")
3535
.addConverterFactory(GsonConverterFactory.create())
36-
.addCallAdapterFactory(RxJavaCallAdapterFactory.create())
36+
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
3737
.build();
3838
mExampleRepository = retrofit.create(ExampleRepository.class);
3939
}

lib/src/main/java/ua/naiksoftware/stomp/OkHttpConnectionProvider.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ public void onClosed(WebSocket webSocket, int code, String reason) {
8282
public void onFailure(WebSocket webSocket, Throwable t, Response response) {
8383
emitLifecycleEvent(new LifecycleEvent(LifecycleEvent.Type.ERROR, new Exception(t)));
8484
}
85+
86+
@Override
87+
public void onClosing(final WebSocket webSocket, final int code, final String reason) {
88+
webSocket.close(code, reason);
89+
}
8590
}
8691

8792
);

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
import java.util.ArrayList;
88
import java.util.Collections;
9-
import java.util.HashMap;
109
import java.util.List;
1110
import java.util.UUID;
11+
import java.util.concurrent.ConcurrentHashMap;
1212

1313
import java8.util.StringJoiner;
1414
import java8.util.concurrent.CompletableFuture;
@@ -33,14 +33,14 @@ public class StompClient {
3333

3434
private final String tag = StompClient.class.getSimpleName();
3535
private final ConnectionProvider mConnectionProvider;
36-
private HashMap<String, String> mTopics;
36+
private ConcurrentHashMap<String, String> mTopics;
3737
private boolean mConnected;
3838
private boolean isConnecting;
3939

4040
private PublishSubject<StompMessage> mMessageStream;
4141
private CompletableFuture<Boolean> mConnectionFuture;
4242
private Completable mConnectionComplete;
43-
private HashMap<String, Observable<StompMessage>> mStreamMap;
43+
private ConcurrentHashMap<String, Observable<StompMessage>> mStreamMap;
4444
private Parser parser;
4545
private Subscription lifecycleSub;
4646
private List<StompHeader> mHeaders;
@@ -49,7 +49,7 @@ public class StompClient {
4949
public StompClient(ConnectionProvider connectionProvider) {
5050
mConnectionProvider = connectionProvider;
5151
mMessageStream = PublishSubject.create();
52-
mStreamMap = new HashMap<>();
52+
mStreamMap = new ConcurrentHashMap<>();
5353
resetStatus();
5454
parser = Parser.NONE;
5555
}
@@ -252,7 +252,7 @@ private boolean matches(String path, StompMessage msg) {
252252
private Completable subscribePath(String destinationPath, @Nullable List<StompHeader> headerList) {
253253
String topicId = UUID.randomUUID().toString();
254254

255-
if (mTopics == null) mTopics = new HashMap<>();
255+
if (mTopics == null) mTopics = new ConcurrentHashMap<>();
256256

257257
// Only continue if we don't already have a subscription to the topic
258258
if (mTopics.containsKey(destinationPath)) {

0 commit comments

Comments
 (0)