package com.qmth.themis.business.enums;

import com.google.common.collect.ImmutableMap;

import java.util.Map;
import java.util.Objects;

/**
 * @Description: 腾讯云事件回调类型
 * @Param:
 * @return:
 * @Author: wangliang
 * @Date: 2022/4/27
 */
public enum TencentEventTypeEnum {

    EVENT_TYPE_CREATE_ROOM("101", "创建房间", null),

    EVENT_TYPE_DISMISS_ROOM("102", "解散房间", null),

    EVENT_TYPE_ENTER_ROOM("103", "进入房间", ImmutableMap.of(
            "1", "正常进房",
            "2", "切换网络",
            "3", "超时重试",
            "4", "跨房连麦进房"
    )),

    EVENT_TYPE_EXIT_ROOM("104", "退出房间", ImmutableMap.of(
            "1", "正常退房",
            "2", "超时离开",
            "3", "房间用户被移出",
            "4", "取消连麦退房",
            "5", "强杀"
    )),

    EVENT_TYPE_CHANGE_ROLE("105", "切换角色", null),

    EVENT_TYPE_START_VIDEO("201", "开始推送视频数据", null),

    EVENT_TYPE_STOP_VIDEO("202", "停止推送视频数据", null),

    EVENT_TYPE_START_AUDIO("203", "开始推送音频数据", null),

    EVENT_TYPE_STOP_AUDIO("204", "停止推送音频数据", null),

    EVENT_TYPE_START_ASSIT("205", "开始推送辅路数据", null),

    EVENT_TYPE_STOP_ASSIT("206", "停止推送辅路数据", null);

    private TencentEventTypeEnum(String code, String title, Map<String, String> map) {
        this.code = code;
        this.title = title;
        this.map = map;
    }

    private String code;

    private String title;

    private Map<String, String> map;

    public Map<String, String> getMap() {
        return map;
    }

    public String getCode() {
        return code;
    }

    public String getTitle() {
        return title;
    }

    /**
     * 状态转换 toName
     *
     * @param code
     * @return
     */
    public static TencentEventTypeEnum convertToName(String code) {
        for (TencentEventTypeEnum e : TencentEventTypeEnum.values()) {
            if (Objects.equals(code, e.getCode())) {
                return e;
            }
        }
        return null;
    }
}
