mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-27 08:55:54 +03:00
check if existing websocket is Connected
+ refactoring Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
832409a255
commit
12cfd70a8a
1 changed files with 12 additions and 12 deletions
|
@ -82,19 +82,19 @@ public class WebSocketConnectionHelper {
|
|||
|
||||
long userId = isGuest ? -1 : user.getId();
|
||||
|
||||
WebSocketInstance webSocketInstance;
|
||||
if (userId != -1 && webSocketInstanceMap.containsKey(user.getId()) && (webSocketInstance = webSocketInstanceMap.get(user.getId())) != null) {
|
||||
Log.d(TAG, "webSocketInstanceMap already contained webSocketInstance for userId " + user.getId());
|
||||
return webSocketInstance;
|
||||
} else {
|
||||
if (userId == -1) {
|
||||
deleteExternalSignalingInstanceForUserEntity(userId);
|
||||
}
|
||||
webSocketInstance = new WebSocketInstance(user, generatedURL, webSocketTicket);
|
||||
Log.d(TAG, "created new webSocketInstance for userId " + user.getId());
|
||||
webSocketInstanceMap.put(user.getId(), webSocketInstance);
|
||||
WebSocketInstance webSocketInstance = webSocketInstanceMap.get(user.getId());
|
||||
|
||||
if (userId != -1 && webSocketInstance != null && webSocketInstance.isConnected()) {
|
||||
return webSocketInstance;
|
||||
}
|
||||
|
||||
if (userId == -1) {
|
||||
deleteExternalSignalingInstanceForUserEntity(userId);
|
||||
}
|
||||
|
||||
webSocketInstance = new WebSocketInstance(user, generatedURL, webSocketTicket);
|
||||
webSocketInstanceMap.put(user.getId(), webSocketInstance);
|
||||
return webSocketInstance;
|
||||
}
|
||||
|
||||
public static synchronized void deleteExternalSignalingInstanceForUserEntity(long id) {
|
||||
|
@ -108,7 +108,7 @@ public class WebSocketConnectionHelper {
|
|||
}
|
||||
|
||||
HelloOverallWebSocketMessage getAssembledHelloModel(User user, String ticket) {
|
||||
int apiVersion = ApiUtils.getSignalingApiVersion(user, new int[] {ApiUtils.APIv3, 2, 1});
|
||||
int apiVersion = ApiUtils.getSignalingApiVersion(user, new int[]{ApiUtils.APIv3, 2, 1});
|
||||
|
||||
HelloOverallWebSocketMessage helloOverallWebSocketMessage = new HelloOverallWebSocketMessage();
|
||||
helloOverallWebSocketMessage.setType("hello");
|
||||
|
|
Loading…
Reference in a new issue