浏览代码

Merge pull request #2586 from nextcloud/fix-joining-call-when-signaling-messages-overtake-the-response

Fix joining call when signaling messages overtake the response
Marcel Hibbe 2 年之前
父节点
当前提交
dfa2b66eec
共有 1 个文件被更改,包括 20 次插入2 次删除
  1. 20 2
      app/src/main/java/com/nextcloud/talk/activities/CallActivity.java

+ 20 - 2
app/src/main/java/com/nextcloud/talk/activities/CallActivity.java

@@ -1442,7 +1442,9 @@ public class CallActivity extends CallBaseActivity {
                 @Override
                 @Override
                 public void onNext(@io.reactivex.annotations.NonNull GenericOverall genericOverall) {
                 public void onNext(@io.reactivex.annotations.NonNull GenericOverall genericOverall) {
                     if (currentCallStatus != CallStatus.LEAVING) {
                     if (currentCallStatus != CallStatus.LEAVING) {
-                        setCallState(CallStatus.JOINED);
+                        if (currentCallStatus != CallStatus.IN_CONVERSATION) {
+                            setCallState(CallStatus.JOINED);
+                        }
 
 
                         ApplicationWideCurrentRoomHolder.getInstance().setInCall(true);
                         ApplicationWideCurrentRoomHolder.getInstance().setInCall(true);
                         ApplicationWideCurrentRoomHolder.getInstance().setDialing(false);
                         ApplicationWideCurrentRoomHolder.getInstance().setDialing(false);
@@ -1851,6 +1853,8 @@ public class CallActivity extends CallBaseActivity {
 
 
         Log.d(TAG, "   currentSessionId is " + currentSessionId);
         Log.d(TAG, "   currentSessionId is " + currentSessionId);
 
 
+        boolean isSelfInCall = false;
+
         for (HashMap<String, Object> participant : users) {
         for (HashMap<String, Object> participant : users) {
             long inCallFlag = (long) participant.get("inCall");
             long inCallFlag = (long) participant.get("inCall");
             if (!participant.get("sessionId").equals(currentSessionId)) {
             if (!participant.get("sessionId").equals(currentSessionId)) {
@@ -1874,9 +1878,12 @@ public class CallActivity extends CallBaseActivity {
                 userIdsBySessionId.put(participant.get("sessionId").toString(), userId);
                 userIdsBySessionId.put(participant.get("sessionId").toString(), userId);
             } else {
             } else {
                 Log.d(TAG, "   inCallFlag of currentSessionId: " + inCallFlag);
                 Log.d(TAG, "   inCallFlag of currentSessionId: " + inCallFlag);
+                isSelfInCall = inCallFlag != 0;
                 if (inCallFlag == 0 && currentCallStatus != CallStatus.LEAVING && ApplicationWideCurrentRoomHolder.getInstance().isInCall()) {
                 if (inCallFlag == 0 && currentCallStatus != CallStatus.LEAVING && ApplicationWideCurrentRoomHolder.getInstance().isInCall()) {
                     Log.d(TAG, "Most probably a moderator ended the call for all.");
                     Log.d(TAG, "Most probably a moderator ended the call for all.");
                     hangup(true);
                     hangup(true);
+
+                    return;
                 }
                 }
             }
             }
         }
         }
@@ -1887,6 +1894,17 @@ public class CallActivity extends CallBaseActivity {
             }
             }
         }
         }
 
 
+        if (!isSelfInCall) {
+            Log.d(TAG, "Self not in call, disconnecting from all other sessions");
+
+            for (String sessionId : oldSessions) {
+                Log.d(TAG, "   oldSession that will be removed is: " + sessionId);
+                endPeerConnection(sessionId, false);
+            }
+
+            return;
+        }
+
         // Calculate sessions that left the call
         // Calculate sessions that left the call
         List<String> disconnectedSessions = new ArrayList<>(oldSessions);
         List<String> disconnectedSessions = new ArrayList<>(oldSessions);
         disconnectedSessions.removeAll(newSessions);
         disconnectedSessions.removeAll(newSessions);
@@ -1894,7 +1912,7 @@ public class CallActivity extends CallBaseActivity {
         // Calculate sessions that join the call
         // Calculate sessions that join the call
         newSessions.removeAll(oldSessions);
         newSessions.removeAll(oldSessions);
 
 
-        if (!isConnectionEstablished() && currentCallStatus != CallStatus.CONNECTING) {
+        if (currentCallStatus == CallStatus.LEAVING) {
             return;
             return;
         }
         }