package cn.sikey.websocket.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @Author: nelson
 * @Date: 2025/5/30
 * @Description: 消息状态
 */
@AllArgsConstructor
@Getter
public enum MessageStatus {

    /**
     * 未读 (初始状态)
     */
    DEFAULT(0),

    /**
     * 离线队列
     */
    OFFLINE_QUEUE(3),

    /**
     * 等待 ACK
     */
    WAIT_ACK(8),

    /**
     * 已收到 ACK
     */
    RECEIVED_ACK(9),

    /**
     * 已读
     */
    READ(10);

    private final Integer value;

    public static MessageStatus valueOf(Integer value) {
        MessageStatus[] statuses = MessageStatus.values();
        for (MessageStatus status : statuses) {
            if (status.getValue().equals(value)) {
                return status;
            }
        }
        throw new RuntimeException("Invalid value");
    }

}
