mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-19 11:39:42 +01:00
add checks to reconnect websocket
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
12cfd70a8a
commit
1f2d759307
@ -56,6 +56,7 @@ import java.io.IOException
|
|||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@AutoInjector(NextcloudTalkApplication::class)
|
@AutoInjector(NextcloudTalkApplication::class)
|
||||||
|
@Suppress("TooManyFunctions")
|
||||||
class WebSocketInstance internal constructor(
|
class WebSocketInstance internal constructor(
|
||||||
conversationUser: User,
|
conversationUser: User,
|
||||||
connectionUrl: String,
|
connectionUrl: String,
|
||||||
@ -388,6 +389,10 @@ class WebSocketInstance internal constructor(
|
|||||||
)
|
)
|
||||||
if (!isConnected || reconnecting) {
|
if (!isConnected || reconnecting) {
|
||||||
messagesQueue.add(message)
|
messagesQueue.add(message)
|
||||||
|
|
||||||
|
if (!reconnecting) {
|
||||||
|
restartWebSocket()
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (roomToken == "") {
|
if (roomToken == "") {
|
||||||
Log.d(TAG, "sending 'leave room' via websocket")
|
Log.d(TAG, "sending 'leave room' via websocket")
|
||||||
@ -399,7 +404,11 @@ class WebSocketInstance internal constructor(
|
|||||||
} else {
|
} else {
|
||||||
Log.d(TAG, "Sending join room message via websocket")
|
Log.d(TAG, "Sending join room message via websocket")
|
||||||
currentNormalBackendSession = normalBackendSession
|
currentNormalBackendSession = normalBackendSession
|
||||||
internalWebSocket!!.send(message)
|
|
||||||
|
if (!internalWebSocket!!.send(message)) {
|
||||||
|
messagesQueue.add(message)
|
||||||
|
restartWebSocket()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e: IOException) {
|
} catch (e: IOException) {
|
||||||
@ -414,8 +423,15 @@ class WebSocketInstance internal constructor(
|
|||||||
)
|
)
|
||||||
if (!isConnected || reconnecting) {
|
if (!isConnected || reconnecting) {
|
||||||
messagesQueue.add(message)
|
messagesQueue.add(message)
|
||||||
|
|
||||||
|
if (!reconnecting) {
|
||||||
|
restartWebSocket()
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
internalWebSocket!!.send(message)
|
if (!internalWebSocket!!.send(message)) {
|
||||||
|
messagesQueue.add(message)
|
||||||
|
restartWebSocket()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (e: IOException) {
|
} catch (e: IOException) {
|
||||||
Log.e(TAG, "Failed to serialize signaling message", e)
|
Log.e(TAG, "Failed to serialize signaling message", e)
|
||||||
|
Loading…
Reference in New Issue
Block a user