package com.rong.io.live.helper;

import android.text.TextUtils;

import com.rong.io.live.message.RCChatJoinRoomMessage;
import com.rong.io.live.message.RCOnSnappingUpMessage;

import io.rong.imlib.model.MessageContent;
import io.rong.imlib.model.UserInfo;

/**
 * Author by pq, Date on 2022/6/20.
 */
public class LiveMemberHelper {
    public static String getMessageName(MessageContent messageContent) {
        String name = "";
        UserInfo userInfo = messageContent.getUserInfo();
        if (userInfo != null) {
            name = userInfo.getName();
        }
        if (TextUtils.isEmpty(name)) {
            if (messageContent instanceof RCChatJoinRoomMessage) {
                RCChatJoinRoomMessage joinRoomMessage = (RCChatJoinRoomMessage) messageContent;
                name = joinRoomMessage.getUserName();
            }
            if (messageContent instanceof RCOnSnappingUpMessage) {
                RCOnSnappingUpMessage onSnappingUpMessage = (RCOnSnappingUpMessage) messageContent;
                name = onSnappingUpMessage.getUserName();
            }
        }
        if (TextUtils.isEmpty(name)) {
            name = "用户";
        }
        return name;
    }
}
