Try to run IncomingMessageObserver more aggressively.

This commit is contained in:
Cody Henthorne
2025-06-25 14:12:24 -04:00
parent c0340be3ce
commit a043b4e573
4 changed files with 21 additions and 8 deletions

View File

@@ -175,6 +175,12 @@ class IncomingMessageObserver(
}
}
}
authWebSocket.addKeepAliveChangeListener {
lock.withLock {
connectionNecessarySemaphore.release()
}
}
}
fun notifyRegistrationStateChanged() {
@@ -236,12 +242,12 @@ class IncomingMessageObserver(
val needsConnectionString = if (conclusion) "Needs Connection" else "Does Not Need Connection"
Log.d(TAG, "[$needsConnectionString] Network: $hasNetwork, Foreground: $appVisibleSnapshot, Time Since Last Interaction: $lastInteractionString, FCM: $fcmEnabled, WS Connected: $websocketAlreadyOpen, Registered: $registered, Proxy: $hasProxy, Force websocket: $forceWebsocket")
Log.d(TAG, "[$needsConnectionString] Network: $hasNetwork, Foreground: $appVisibleSnapshot, Time Since Last Interaction: $lastInteractionString, FCM: $fcmEnabled, WS Open or Keep-alives: $websocketAlreadyOpen, Registered: $registered, Proxy: $hasProxy, Force websocket: $forceWebsocket")
return conclusion
}
private fun isConnectionAvailable(): Boolean {
return authWebSocket.stateSnapshot == WebSocketConnectionState.CONNECTED
return authWebSocket.stateSnapshot == WebSocketConnectionState.CONNECTED || authWebSocket.shouldSendKeepAlives()
}
private fun waitForConnectionNecessary() {

View File

@@ -74,7 +74,7 @@ class SignalWebSocketHealthMonitor(
.distinctUntilChanged()
.subscribeBy { onStateChanged(it) }
webSocket.keepAliveChangedListener = { executor.execute(this::updateKeepAliveSenderStatus) }
webSocket.addKeepAliveChangeListener { executor.execute(this::updateKeepAliveSenderStatus) }
}
}