package com.yonge.cooleshow.biz.dal.dto;

import lombok.Getter;

/**
 * Description
 *
 * @author liujunchi
 * @date 2023-03-02
 */
@Getter
public enum ETencentTRTCCallbackCommand {

    // 房间事件
    EVENT_TYPE_CREATE_ROOM("101", "创建房间"),
    EVENT_TYPE_DISMISS_ROOM("102", "解散房间"),
    EVENT_TYPE_ENTER_ROOM("103", "进入房间"),
    EVENT_TYPE_EXIT_ROOM("104", "退出房间"),

    // 媒体事件
    EVENT_TYPE_START_VIDEO("201", "开始推送视频数据"),
    EVENT_TYPE_STOP_VIDEO("202", "停止推送视频数据"),
    EVENT_TYPE_START_AUDIO("203", "开始推送音频数据"),
    EVENT_TYPE_STOP_AUDIO("204", "停止推送音频数据"),
    EVENT_TYPE_START_ASSIT("205", "开始推送辅路数据"),
    EVENT_TYPE_STOP_ASSIT("206", "停止推送辅路数据"),

    EVENT_DEFAULT("-1", "默认无效事件"),
    ;

    private final String command;
    private final String desc;

    private final Integer code;

    ETencentTRTCCallbackCommand(String command, String desc) {
        this.command = command;
        this.desc = desc;

        // 枚举转换对象
        this.code = Integer.parseInt(command);
    }

    /**
     * 回调事件对象枚举
     * @param eventType 事件类型
     * @return ETencentTRTCCallbackCommand
     */
    public static ETencentTRTCCallbackCommand get(Integer eventType) {
        for (ETencentTRTCCallbackCommand e : ETencentTRTCCallbackCommand.values()) {
            if (e.getCode().equals(eventType)) {
                return e;
            }
        }
        return EVENT_DEFAULT;
    }
}
