package com.swago.room.lianmai

import com.swago.baseswago.model.live.mic.LianMaiIMModel

object LianMaiManager {

    /**
     * 0  不在连麦状态主播或户都
     * 1  连麦状态的主播或用户
     * 2  正在观看主播和用户连麦状态的用户
     * 3 正在申请连麦状态的用户
     * 4 正在申请连麦同时又在观看主播和用户连麦状态的用户
     */
    var lianMaiState = 0

    var lianMaiIMModel:LianMaiIMModel? = null

    var lianMaiIsComplete = false

    //当前正在连麦的id
    var lianMaiId = ""

    fun clearData(){
        lianMaiState = 0
        lianMaiIMModel = null
        lianMaiIsComplete = false
        lianMaiId = ""
    }



    private val listListener = ArrayList<ILianMaiListener>()

    fun addLianMaiListener(iLianMaiListener: ILianMaiListener){
        listListener.add(iLianMaiListener)
    }

    fun removeLianMaiListener(iLianMaiListener: ILianMaiListener){
        listListener.remove(iLianMaiListener)
    }

    fun dispatchStartLianMai(imModel: LianMaiIMModel){
        listListener.forEach {
            it.startLianMai(imModel)
        }
    }

    fun dispatchStopLianMai(imModel: LianMaiIMModel){
        listListener.forEach {
            it.stopLianMai(imModel)
        }
    }
}