fix: last resort for socket disconnect crash

Signed-off-by: Infi <infi@infi.sh>
This commit is contained in:
Infi 2024-06-06 18:42:40 +02:00
parent 70d572d93a
commit 16216ce6bf
1 changed files with 21 additions and 13 deletions

View File

@ -167,24 +167,32 @@ object RevoltAPI {
try {
RealtimeSocket.connect(sessionToken)
} catch (e: Exception) {
if (e is SocketException) {
Log.d(
"RevoltAPI",
"Socket closed, probably no big deal /// " + e.message
)
} else {
Log.e("RevoltAPI", "WebSocket error", e)
try {
if (e is SocketException) {
Log.d(
"RevoltAPI",
"Socket closed, probably no big deal /// " + e.message
)
} else {
Log.e("RevoltAPI", "WebSocket error", e)
}
RealtimeSocket.updateDisconnectionState(DisconnectionState.Disconnected)
} catch (e: Exception) {
Sentry.captureMessage("Error in socket error handling: $e")
}
RealtimeSocket.updateDisconnectionState(DisconnectionState.Disconnected)
}
}
} catch (e: Exception) {
if (e is InterruptedException) {
Log.d("RevoltAPI", "Socket interrupted")
} else {
Log.e("RevoltAPI", "WebSocket error", e)
try {
if (e is InterruptedException) {
Log.d("RevoltAPI", "Socket interrupted")
} else {
Log.e("RevoltAPI", "WebSocket error", e)
}
RealtimeSocket.updateDisconnectionState(DisconnectionState.Disconnected)
} catch (e: Exception) {
Sentry.captureMessage("Error in socket error handling: $e")
}
RealtimeSocket.updateDisconnectionState(DisconnectionState.Disconnected)
}
}
}