package com.adealink.weparty.im.session.mesasge

import com.adealink.frame.data.json.froJsonErrorNull
import com.adealink.weparty.module.playmate.data.SayWelcomeData
import com.tencent.imsdk.v2.V2TIMMessage
import com.tencent.qcloud.tuikit.timcommon.bean.TUIMessageBean
import com.tencent.qcloud.tuikit.timcommon.bean.TUIReplyQuoteBean
import com.tencent.qcloud.tuikit.tuichat.bean.message.reply.TextReplyQuoteBean

class PlaymateSayWelcomeTextMessageBean : TUIMessageBean() {

    var data: SayWelcomeData? = null
    override fun onGetDisplayString(): String? {
        return data?.text
    }

    override fun onProcessMessage(v2TIMMessage: V2TIMMessage) {
        val byte = v2TIMMessage.customElem?.data ?: return
        val dataStr = String(byte)
        val playmateData = froJsonErrorNull<SayWelcomeData>(dataStr)
        //填充数据
        this.data = playmateData
    }

    override fun getReplyQuoteBeanClass(): Class<out TUIReplyQuoteBean<*>?> {
        return TextReplyQuoteBean::class.java
    }
}
