|
|
@@ -20,11 +20,14 @@ import com.adealink.weparty.room.sdk.controller.IJoinController
|
|
|
import com.adealink.weparty.room.sdk.listener.IJoinListener
|
|
|
import com.tencent.cloud.tuikit.engine.extension.TUILiveListManager
|
|
|
import io.trtc.tuikit.atomicxcore.api.CompletionHandler
|
|
|
+import io.trtc.tuikit.atomicxcore.api.live.LiveEndedReason
|
|
|
import io.trtc.tuikit.atomicxcore.api.live.LiveInfo
|
|
|
import io.trtc.tuikit.atomicxcore.api.live.LiveInfoCompletionHandler
|
|
|
+import io.trtc.tuikit.atomicxcore.api.live.LiveListListener
|
|
|
import io.trtc.tuikit.atomicxcore.api.live.LiveListStore
|
|
|
import io.trtc.tuikit.atomicxcore.api.live.StopLiveCompletionHandler
|
|
|
import kotlinx.coroutines.async
|
|
|
+import kotlinx.coroutines.launch
|
|
|
import kotlinx.coroutines.suspendCancellableCoroutine
|
|
|
import kotlinx.coroutines.withContext
|
|
|
import kotlin.coroutines.resume
|
|
|
@@ -38,6 +41,23 @@ open class JoinController(override val ctx: IRoomContext, serialHandler: Handler
|
|
|
override var joiningRoomId: String? = null
|
|
|
override var joinedRoomInfo: LiveInfo? = null
|
|
|
|
|
|
+ private val liveListListener = object : LiveListListener() {
|
|
|
+ override fun onLiveEnded(liveId: String, reason: LiveEndedReason, message: String) {
|
|
|
+ if (liveId != joinedRoomInfo?.liveID) return
|
|
|
+ notifyLiveEnd(liveId, reason)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun onRoomIn(flowStateInfo: FlowStateInfo) {
|
|
|
+ super.onRoomIn(flowStateInfo)
|
|
|
+ LiveListStore.shared().addLiveListListener(liveListListener)
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun onRoomLeaved(flowStateInfo: FlowStateInfo) {
|
|
|
+ super.onRoomLeaved(flowStateInfo)
|
|
|
+ LiveListStore.shared().removeLiveListListener(liveListListener)
|
|
|
+ }
|
|
|
+
|
|
|
override fun onRoomStateChanged(
|
|
|
fromState: RoomState,
|
|
|
toState: RoomState,
|
|
|
@@ -235,6 +255,13 @@ open class JoinController(override val ctx: IRoomContext, serialHandler: Handler
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private fun notifyLiveEnd(roomId: String, reason: LiveEndedReason) {
|
|
|
+ Log.i(TAG_ROOM_FLOW, "notifyLiveEnd, roomId:$roomId, reason:${reason.name}")
|
|
|
+ launch {
|
|
|
+ leaveRoom(LeaveRoomReason.LIVE_END, true)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
private fun changeRoomState(toState: RoomState, flowStateInfo: FlowStateInfo) {
|
|
|
Log.i(
|