Skip to content

Commit 21595ed

Browse files
authored
Fix WebSocket connection notification issue (#885)
* bugfix: After fixing the failure of RTC reconnection and WebSocket connection, no notification was sent to the upper-layer application. * bugfix: Remove unnecessary code * bugfix: Remove unnecessary code
1 parent cb2e12a commit 21595ed

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

livekit-android-sdk/src/main/java/io/livekit/android/room/SignalClient.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,9 @@ constructor(
349349
LKLog.e(e) { "failed to validate connection" }
350350
}
351351

352+
val wasConnected = isConnected
353+
val wasConnecting = joinContinuation != null
354+
352355
if (reason != null) {
353356
LKLog.e(t) { "websocket failure: $reason" }
354357
val error = Exception(reason)
@@ -361,11 +364,11 @@ constructor(
361364
}
362365
joinContinuation = null
363366

364-
val wasConnected = isConnected
365-
366-
if (wasConnected) {
367+
if (wasConnected || wasConnecting) {
367368
// onClosing/onClosed will not be called after onFailure.
368369
// Handle websocket closure here.
370+
// Also handle the case where failure occurs during a reconnect attempt (wasConnecting),
371+
// where isConnected is already false but the upper layer still needs to be notified.
369372
handleWebSocketClose(
370373
reason = reason ?: response?.toString() ?: t.localizedMessage ?: "websocket failure",
371374
code = response?.code ?: CLOSE_REASON_WEBSOCKET_FAILURE,

0 commit comments

Comments
 (0)