Skip to content

Commit e0e1c7d

Browse files
author
Tarek Loubani
committed
fix(call): ignore stale roomJoined events that fire before joinRoomAndCall
When the app launches and immediately joins an existing call, the WebSocket may already be connected from a previous session. The server sends a stale roomJoined event before joinRoomAndCall() is called, causing performCall() to fire prematurely. Later when joinRoomAndCall runs, the WebSocket does a local join and the server never re-sends the participant list. The call stays stuck in JOINED and never transitions to IN_CONVERSATION. Add joinRoomInitiated flag to guard the roomJoined handler against stale events. Only process roomJoined after joinRoomAndCall has been called. Signed-off-by: Tarek Loubani <tarek@tarek.org>
1 parent b17ec5b commit e0e1c7d

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

app/src/main/java/com/nextcloud/talk/activities/CallActivity.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ class CallActivity : CallBaseActivity() {
302302
private var externalSignalingServer: ExternalSignalingServer? = null
303303
private var webSocketClient: WebSocketInstance? = null
304304
private var webSocketConnectionHelper: WebSocketConnectionHelper? = null
305+
private var joinRoomInitiated = false
305306
private var hasMCU = false
306307
private var hasExternalSignalingServer = false
307308
private var conversationPassword: String? = null
@@ -1521,6 +1522,7 @@ class CallActivity : CallBaseActivity() {
15211522
.toSet()
15221523

15231524
private fun joinRoomAndCall() {
1525+
joinRoomInitiated = true
15241526
callSession = ApplicationWideCurrentRoomHolder.getInstance().session
15251527
val apiVersion = ApiUtils.getConversationApiVersion(conversationUser, intArrayOf(ApiUtils.API_V4, 1))
15261528
Log.d(TAG, "joinRoomAndCall")
@@ -1874,7 +1876,11 @@ class CallActivity : CallBaseActivity() {
18741876
}
18751877

18761878
"roomJoined" -> {
1877-
Log.d(TAG, "onMessageEvent 'roomJoined'")
1879+
Log.d(TAG, "onMessageEvent 'roomJoined' joinRoomInitiated=$joinRoomInitiated")
1880+
if (!joinRoomInitiated) {
1881+
Log.d(TAG, "Ignoring stale roomJoined event (joinRoomAndCall not yet called)")
1882+
return
1883+
}
18781884
startSendingNick()
18791885
if (webSocketCommunicationEvent.getHashMap()!!["roomToken"] == roomToken) {
18801886
performCall()
@@ -1943,6 +1949,7 @@ class CallActivity : CallBaseActivity() {
19431949

19441950
private fun hangup(shutDownView: Boolean, endCallForAll: Boolean) {
19451951
Log.d(TAG, "hangup! shutDownView=$shutDownView")
1952+
joinRoomInitiated = false
19461953
if (shutDownView) {
19471954
setCallState(CallStatus.LEAVING)
19481955
}

0 commit comments

Comments
 (0)