Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't set state to disconnected for normal websocket connection closing #156

Merged
merged 1 commit into from
Jan 15, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Don't set state to disconnected for normal websocket connection closing
- websocket is configured to automatically connect and disconnect when app resumed and paused, respectively
  • Loading branch information
omurovch committed Jan 15, 2021
commit 2323de0e773484a11dd48b742371a3d9a253f4e9
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