Skip to content

Commit

Permalink
Crash fixed on connection restored
Browse files Browse the repository at this point in the history
  • Loading branch information
Liubov Danilina committed Apr 17, 2024
1 parent 9959fa3 commit 951e884
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,11 @@ class SingleStreamListener(

private suspend fun onConnected() {
Log.d(TAG, "onConnected")
subscriber.subscribe(Option(statsDelayMs = 1_000))
try {
subscriber.subscribe(Option(statsDelayMs = 1_000))
} catch (e: MillicastException) {
e.printStackTrace()
}
}

private fun onActive(p0: String?, p1: Array<out String>, p2: String?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import com.millicast.subscribers.ProjectionData
import com.millicast.subscribers.state.ActivityStream
import com.millicast.subscribers.state.LayerData
import com.millicast.subscribers.state.SubscriberConnectionState
import com.millicast.utils.MillicastException
import io.dolby.rtscomponentkit.domain.MultiStreamStatisticsData
import io.dolby.rtscomponentkit.domain.MultiStreamingData
import kotlinx.coroutines.CoroutineScope
Expand Down Expand Up @@ -40,7 +41,8 @@ class MultiStreamListener(
Log.d(TAG, "Listener start")
coroutineScope = CoroutineScope(Dispatchers.IO)

subscriber.state.map { it.connectionState }.collectInLocalScope { state ->
subscriber.state.map { it.connectionState }.distinctUntilChanged().collectInLocalScope { state ->
Log.d(TAG, "New state: $state")
when (state) {
SubscriberConnectionState.Connected -> {
onConnected()
Expand Down Expand Up @@ -144,7 +146,11 @@ class MultiStreamListener(
TAG,
"onConnected, this: $this, thread: ${Thread.currentThread().id}"
)
subscriber.subscribe(options = options)
try {
subscriber.subscribe(options = options)
} catch (e: MillicastException) {
e.printStackTrace()
}
}

private fun onDisconnected() {
Expand Down

0 comments on commit 951e884

Please sign in to comment.