Skip to content

Commit

Permalink
change connection change state as follow
Browse files Browse the repository at this point in the history
  • Loading branch information
jaeyunn15 committed Oct 7, 2023
1 parent c879f31 commit e311945
Showing 1 changed file with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,7 @@ class ThunderStateManager private constructor(
connectionListener.collectState().onEach {
when(it) {
Initialize -> Unit
GetReady -> {
_socketState.updateThunderState(ThunderState.CONNECTING)
openConnection()
}
GetReady -> openConnection()
ShutDown -> closeConnection()
}
}.launchIn(scope)
Expand All @@ -92,7 +89,6 @@ class ThunderStateManager private constructor(
networkState.networkStatus.onEach {
when (it) {
NetworkState.Available -> {
_socketState.updateThunderState(ThunderState.CONNECTING)
openConnection()
}

Expand Down Expand Up @@ -158,6 +154,7 @@ class ThunderStateManager private constructor(
private lateinit var connectionJob: Job
private fun openConnection() {
if (socket == null) {
_socketState.updateThunderState(ThunderState.CONNECTING)
socket = webSocketCore.create()
socket?.let { webSocket ->
webSocket.open()
Expand Down

0 comments on commit e311945

Please sign in to comment.