diff --git a/app/src/main/java/com/nextcloud/talk/controllers/CallController.java b/app/src/main/java/com/nextcloud/talk/controllers/CallController.java index 24fdff292..2c5a36089 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/CallController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/CallController.java @@ -1455,7 +1455,11 @@ public class CallController extends BaseController { } for (MagicPeerConnectionWrapper magicPeerConnectionWrapper : magicPeerConnectionWrapperList) { - oldSesssions.add(magicPeerConnectionWrapper.getSessionId()); + if (externalSignalingServer != null && callSession.equals(magicPeerConnectionWrapper.getSessionId())) { + oldSesssions.add(magicPeerConnectionWrapper.getSessionId()); + } else { + oldSesssions.add(magicPeerConnectionWrapper.getSessionId()); + } } // Calculate sessions that left the call diff --git a/app/src/main/java/com/nextcloud/talk/webrtc/MagicPeerConnectionWrapper.java b/app/src/main/java/com/nextcloud/talk/webrtc/MagicPeerConnectionWrapper.java index b967afb03..5965b6a41 100644 --- a/app/src/main/java/com/nextcloud/talk/webrtc/MagicPeerConnectionWrapper.java +++ b/app/src/main/java/com/nextcloud/talk/webrtc/MagicPeerConnectionWrapper.java @@ -110,7 +110,10 @@ public class MagicPeerConnectionWrapper { } if (peerConnection != null) { - peerConnection.removeStream(localMediaStream); + if (localMediaStream != null) { + peerConnection.removeStream(localMediaStream); + } + peerConnection.close(); peerConnection = null; } diff --git a/app/src/main/java/com/nextcloud/talk/webrtc/MagicWebSocketInstance.java b/app/src/main/java/com/nextcloud/talk/webrtc/MagicWebSocketInstance.java index 44dd84b56..2b7237e80 100644 --- a/app/src/main/java/com/nextcloud/talk/webrtc/MagicWebSocketInstance.java +++ b/app/src/main/java/com/nextcloud/talk/webrtc/MagicWebSocketInstance.java @@ -133,7 +133,7 @@ public class MagicWebSocketInstance extends WebSocketListener { String target = (String) eventOverallWebSocketMessage.getEventMap().get("target"); switch (target) { case "room": - if (eventOverallWebSocketMessage.getType().equals("message") && eventOverallWebSocketMessage.getEventMap() != null) { + if (eventOverallWebSocketMessage.getType().equals("message")) { if (eventOverallWebSocketMessage.getEventMap().containsKey("data")) { Map dataHashMap = (Map) eventOverallWebSocketMessage.getEventMap().get("data"); if (dataHashMap.containsKey("chat")) { @@ -152,11 +152,11 @@ public class MagicWebSocketInstance extends WebSocketListener { } break; case "participants": - if (eventOverallWebSocketMessage.getType().equals("update") && eventOverallWebSocketMessage.getEventMap() != null) { - Map participantsUpdateMap = eventOverallWebSocketMessage.getEventMap(); + if (eventOverallWebSocketMessage.getEventMap().get("type").equals("update")) { HashMap refreshChatHashMap = new HashMap<>(); - refreshChatHashMap.put("roomToken", (String) eventOverallWebSocketMessage.getEventMap().get("roomid")); - refreshChatHashMap.put("jobId", Integer.toString(magicMap.add(participantsUpdateMap.get("users")))); + HashMap updateEventMap = (HashMap) eventOverallWebSocketMessage.getEventMap().get("update"); + refreshChatHashMap.put("roomToken", (String) updateEventMap.get("roomid")); + refreshChatHashMap.put("jobId", Integer.toString(magicMap.add(updateEventMap.get("users")))); eventBus.post(new WebSocketCommunicationEvent("participantsUpdate", refreshChatHashMap)); } break;