package com.swago.room.data

import com.swago.baseswago.baseroom.IRoomActiveListener
import com.swago.baseswago.baseroom.IRoomInfo
import com.swago.baseswago.baseroom.SwagoRoomManager
import com.swago.baseswago.model.MomentModel
import com.swago.room.bean.UserRoomModel
import java.util.concurrent.CopyOnWriteArrayList

/**
 *@date 2021/10/11 14:28
 *description:
 */
object RoomDataManager : IRoomActiveListener{

    val data = CopyOnWriteArrayList<UserRoomModel>()

    fun initData(list:List<MomentModel>?){
        data.clear()
        list?.forEach {
            val userRoomModel = UserRoomModel()
            userRoomModel.momentModel = it
            data.add(userRoomModel)
        }
        SwagoRoomManager.addListener(this)
    }

    override fun changeRoom(iRoomInfo: IRoomInfo) {}

    override fun leaveRoom(iRoomInfo: IRoomInfo) {}

    override fun joinedRoom(iRoomInfo: IRoomInfo) {}

    override fun endRoom(iRoomInfo: IRoomInfo?) {}

    override fun closeRoomed() {
        SwagoRoomManager.removeListener(this)
    }

}