Skip to content

Commit

Permalink
Don't set state to disconnected for normal websocket connection closing
Browse files Browse the repository at this point in the history
- websocket is configured to automatically connect and disconnect when app resumed and paused, respectively
  • Loading branch information
omurovch committed Jan 15, 2021
1 parent dae579f commit 138c7e6
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.app.Application
import com.google.gson.Gson
import com.tinder.scarlet.Event
import com.tinder.scarlet.Scarlet
import com.tinder.scarlet.ShutdownReason
import com.tinder.scarlet.WebSocket
import com.tinder.scarlet.lifecycle.android.AndroidLifecycle
import com.tinder.scarlet.messageadapter.gson.GsonMessageAdapter
Expand Down Expand Up @@ -116,7 +117,7 @@ class InfuraRpcWebSocket(
}

private fun disconnect() {
disposables.clear()
disposables.clear()
}

private fun observeSocket(socket: InfuraWebSocketService) {
Expand All @@ -139,7 +140,9 @@ class InfuraRpcWebSocket(
is WebSocket.Event.OnConnectionClosed -> {
logger.info("On WebSocket Connection Closed")

state = WebSocketState.Disconnected(WebSocketState.DisconnectError.SocketDisconnected(webSocketEvent.shutdownReason.reason))
if (webSocketEvent.shutdownReason.code != ShutdownReason.GRACEFUL.code) {
state = WebSocketState.Disconnected(WebSocketState.DisconnectError.SocketDisconnected(webSocketEvent.shutdownReason.reason))
}
}
is WebSocket.Event.OnConnectionFailed -> {
logger.info("On WebSocket Connection Failed")
Expand Down

0 comments on commit 138c7e6

Please sign in to comment.