package com.zhentao.constant;

/**
 * 聊天系统常量
 */
public class ChatConstants {

    /**
     * 消息类型
     */
    public static class MessageType {
        public static final int TEXT = 1;           // 文本消息
        public static final int IMAGE = 2;          // 图片消息
        public static final int VOICE = 3;          // 语音消息
        public static final int VIDEO = 4;          // 视频消息
        public static final int FILE = 5;           // 文件消息
    }

    /**
     * 发送状态
     */
    public static class SendStatus {
        public static final int SENDING = 1;        // 发送中
        public static final int DELIVERED = 2;      // 已送达
        public static final int READ = 3;           // 已读
        public static final int FAILED = 4;         // 失败
    }

    /**
     * WebSocket消息类型
     */
    public static class WsMessageType {
        public static final String PING = "ping";               // 心跳ping
        public static final String PONG = "pong";               // 心跳pong
        public static final String CHAT = "chat";               // 聊天消息
        public static final String ACK = "ack";                 // 消息确认
        public static final String RECALL = "recall";           // 消息撤回
        public static final String TYPING = "typing";           // 正在输入
        public static final String ONLINE = "online";           // 用户上线
        public static final String OFFLINE = "offline";         // 用户下线
        public static final String READ_RECEIPT = "read";       // 已读回执
        public static final String ERROR = "error";             // 错误消息
    }

    /**
     * Redis Key前缀
     */
    public static class RedisKey {
        public static final String ONLINE_USER = "chat:online:users:";         // 在线用户
        public static final String USER_SESSIONS = "chat:online:sessions:";    // 用户会话
        public static final String UNREAD_COUNT = "chat:unread:count:";        // 未读数
        public static final String CONVERSATION_LIST = "chat:conversation:";   // 会话列表
        public static final String RECENT_MESSAGES = "chat:recent:";           // 最近消息
    }

    /**
     * RabbitMQ常量
     */
    public static class RabbitMQ {
        // 交换机
        public static final String CHAT_EXCHANGE = "chat.exchange";
        public static final String CHAT_DLX_EXCHANGE = "chat.dlx.exchange";    // 死信交换机
        
        // 队列
        public static final String CHAT_QUEUE = "chat.message.queue";
        public static final String CHAT_DLX_QUEUE = "chat.message.dlx.queue";
        
        // 路由键
        public static final String CHAT_ROUTING_KEY = "chat.message";
        public static final String CHAT_DLX_ROUTING_KEY = "chat.message.dlx";
    }

    /**
     * 时间限制（毫秒）
     */
    public static class TimeLimit {
        public static final long MESSAGE_RECALL_TIME = 2 * 60 * 1000;      // 消息撤回时间：2分钟
        public static final long HEARTBEAT_INTERVAL = 30 * 1000;           // 心跳间隔：30秒
        public static final long HEARTBEAT_TIMEOUT = 90 * 1000;            // 心跳超时：90秒
    }

    /**
     * 数量限制
     */
    public static class Limit {
        public static final int MAX_MESSAGE_SIZE = 10 * 1024 * 1024;       // 最大消息大小：10MB
        public static final int MAX_OFFLINE_MESSAGES = 500;                // 最大离线消息数
        public static final int MAX_RETRY_COUNT = 3;                       // 最大重试次数
        public static final int MESSAGE_BATCH_SIZE = 500;                  // 消息批量处理大小
        public static final int MESSAGE_PAGE_SIZE = 20;                    // 消息分页大小
    }
}





