package com.qmth.themis.business.enums;

import java.util.Objects;

/**
 * @Description: webSocket消息类型 enum
 * @Param:
 * @return:
 * @Author: wangliang
 * @Date: 2020/7/22
 */
public enum WebsocketTypeEnum {

    CLIENT_PAPER_DOWNLOAD("客户端已下载试卷", "clientPaperDownload"),

    SYNC_STATUS("状态同步", "syncStatus"),

    SYNC_ACK("同步确认", "syncAck"),

    INVIGILATE_LIVENESS_VERIFY("监考强制活体验证", "invigilateLivenessVerify"),

    INVIGILATE_NOTICE("监考消息", "invigilateNotice"),

    INVIGILATE_NOTICE_ACK("监考消息确认", "invigilateNoticeAck"),

    INVIGILATE_STOP_EXAM("监考强制收卷", "invigilateStopExam"),

    BREACH_STOP_EXAM("预警强制收卷", "breachStopExam"),

//    HAND_STOP_EXAM("手动收卷", "handStopExam"),

    EXAM_START("考试开始", "examStart"),

    EXAM_STOP("考试结束", "examStop"),

    MOBILE_ANSWER_READY("移动端拍照/录音扫描完成", "mobileAnswerReady"),

    MOBILE_ANSWER_UPLOAD("移动端拍照/录音上传成功", "mobileAnswerUpload"),

    MOBILE_MONITOR_START("移动端监控开始", "mobileMonitorStart"),

    MOBILE_MONITOR_STOP("移动端监控停止", "mobileMonitorStop"),

    MOBILE_MONITOR_STATUS("移动端监控状态", "mobileMonitorStatus"),

    EXAM_AUDIO("考试语音", "examAudio"),

    EXAM_EXIT("考试退出", "examExit");

    private String code;
    private String desc;

    private WebsocketTypeEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    /**
     * 状态转换 toName
     *
     * @param value
     * @return
     */
    public static String convertToName(String value) {
        for (WebsocketTypeEnum e : WebsocketTypeEnum.values()) {
            if (Objects.equals(value.trim(), e.getDesc())) {
                return e.name();
            }
        }
        return null;
    }
}
