check if existing websocket is Connected

+ refactoring

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
Marcel Hibbe 2023-07-14 17:26:44 +02:00
parent 832409a255
commit 12cfd70a8a
No known key found for this signature in database
GPG Key ID: C793F8B59F43CE7B

View File

@ -82,20 +82,20 @@ public class WebSocketConnectionHelper {
long userId = isGuest ? -1 : user.getId(); long userId = isGuest ? -1 : user.getId();
WebSocketInstance webSocketInstance; WebSocketInstance webSocketInstance = webSocketInstanceMap.get(user.getId());
if (userId != -1 && webSocketInstanceMap.containsKey(user.getId()) && (webSocketInstance = webSocketInstanceMap.get(user.getId())) != null) {
Log.d(TAG, "webSocketInstanceMap already contained webSocketInstance for userId " + user.getId()); if (userId != -1 && webSocketInstance != null && webSocketInstance.isConnected()) {
return webSocketInstance; return webSocketInstance;
} else { }
if (userId == -1) { if (userId == -1) {
deleteExternalSignalingInstanceForUserEntity(userId); deleteExternalSignalingInstanceForUserEntity(userId);
} }
webSocketInstance = new WebSocketInstance(user, generatedURL, webSocketTicket); webSocketInstance = new WebSocketInstance(user, generatedURL, webSocketTicket);
Log.d(TAG, "created new webSocketInstance for userId " + user.getId());
webSocketInstanceMap.put(user.getId(), webSocketInstance); webSocketInstanceMap.put(user.getId(), webSocketInstance);
return webSocketInstance; return webSocketInstance;
} }
}
public static synchronized void deleteExternalSignalingInstanceForUserEntity(long id) { public static synchronized void deleteExternalSignalingInstanceForUserEntity(long id) {
WebSocketInstance webSocketInstance; WebSocketInstance webSocketInstance;