fix: some websocket related crash
Signed-off-by: Infi <infi@infi.sh>
This commit is contained in:
parent
bfd328c31e
commit
226b455730
|
|
@ -39,6 +39,7 @@ import kotlinx.serialization.ExperimentalSerializationApi
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import kotlinx.serialization.cbor.Cbor
|
import kotlinx.serialization.cbor.Cbor
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
|
import java.net.SocketException
|
||||||
import chat.revolt.api.schemas.Channel as ChannelSchema
|
import chat.revolt.api.schemas.Channel as ChannelSchema
|
||||||
|
|
||||||
const val REVOLT_BASE = "https://api.revolt.chat"
|
const val REVOLT_BASE = "https://api.revolt.chat"
|
||||||
|
|
@ -156,7 +157,19 @@ object RevoltAPI {
|
||||||
socketCoroutine = CoroutineScope(Dispatchers.IO).launch {
|
socketCoroutine = CoroutineScope(Dispatchers.IO).launch {
|
||||||
try {
|
try {
|
||||||
withContext(realtimeContext) {
|
withContext(realtimeContext) {
|
||||||
RealtimeSocket.connect(sessionToken)
|
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)
|
||||||
|
}
|
||||||
|
RealtimeSocket.updateDisconnectionState(DisconnectionState.Disconnected)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
if (e is InterruptedException) {
|
if (e is InterruptedException) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue