package com.adealink.weparty.room.sdk.controller

import com.adealink.frame.base.IError
import com.adealink.frame.base.Rlt
import com.adealink.frame.room.data.FlowStateInfo
import com.adealink.frame.room.data.JoinRoomReq
import com.adealink.frame.room.data.LeaveRoomReason
import com.adealink.frame.room.data.RoomState
import com.adealink.weparty.room.sdk.listener.IJoinListener
import io.trtc.tuikit.atomicxcore.api.live.LiveInfo

interface IJoinController<L : IJoinListener> : IController<L> {

    var joiningRoomId: String? //正在加入的房间
    var joinedRoomInfo: LiveInfo? //加入的房间信息

    /**
     * 获取加入的房间id
     */
    fun getJoinedRoomId(): String?

    fun isOwner(): Boolean

    /**
     * 是否进房或在房
     */
    fun isRoomJoiningOrJoined(): Boolean

    suspend fun suspendJoinRoom(req: JoinRoomReq): Rlt<Any>

    /**
     * 获取进房状态
     */
    fun getJoinRoomState(): RoomState

    fun getJoinFlowData(): FlowStateInfo

    /**
     * 离开直播(下麦+退房)
     */
    suspend fun leaveRoom(
        reason: LeaveRoomReason = LeaveRoomReason.INITIATIVE,
        leaveUI: Boolean = false
    )

    /**
     * 结束直播(解散房间)
     */
    suspend fun closeRoom(
        reason: LeaveRoomReason = LeaveRoomReason.INITIATIVE
    )

}

interface JoinChannelCallback {

    fun onSuccess(channel: String)

    fun onFailed(channel: String, error: IError)

}