package com.swago.baseswago.baseroom.viewmodel

import android.app.Application
import com.swago.baseswago.baseroom.IRoomActiveListener
import com.swago.baseswago.baseroom.SwagoRoomManager
import com.swago.baseswago.im.IMGroupNewMsgListener
import com.swago.baseswago.util.BaseViewModel

/**
 *@date 2021/10/4 10:19
 *description:
 */
abstract class AbsMsgVm(application: Application) : BaseViewModel(application), IRoomActiveListener {
    val imGroupNewMsgListener = IMGroupNewMsgListener()

    fun init(){
        SwagoRoomManager.addListener(this)
        imGroupNewMsgListener.attach()
        receiveMsg()
    }

    abstract fun receiveMsg()

    override fun onCleared() {
        super.onCleared()
        imGroupNewMsgListener.detach()
        SwagoRoomManager.removeListener(this)

    }
}