using MessagePack;
using System;

namespace SHH.Contracts
{
    /// <summary>
    /// 服务端身份注册信息 (DTO)
    /// <para>用于服务端主动连上客户端后，上报自身的端口和身份信息</para>
    /// </summary>
    [MessagePackObject]
    public class RegisterPayload
    {
        #region --- 0. 协议自描述 ---

        /// <summary>
        /// 协议类型标识 (人工可读)
        /// </summary>
        [Key(0)]
        public string Protocol { get; set; } = ProtocolHeaders.ServerRegister;

        #endregion

        #region --- 1. 身份标识 ---

        /// <summary>
        /// 进程 ID (用于区分同一台机器上的多个实例)
        /// </summary>
        [Key(1)]
        public int ProcessId { get; set; }

        /// <summary>
        /// 实例唯一标识符
        /// <para>启动时通过命令行传入，例如 "Gateway_Factory_A"</para>
        /// </summary>
        [Key(2)]
        public string InstanceId { get; set; }

        /// <summary>
        /// 服务端版本号
        /// </summary>
        [Key(3)]
        public string Version { get; set; } = "1.0.0";

        #endregion

        #region --- 2. 网络诊断信息 (用于运维) ---

        /// <summary>
        /// 服务端所在的局域网 IP
        /// <para>客户端无法直接连接此IP(因为可能是内网)，但运维人员需要知道</para>
        /// </summary>
        [Key(4)]
        public string ServerIp { get; set; }

        /// <summary>
        /// WebAPI 监听端口 (HTTP)
        /// <para>用于运维人员打开 Swagger 进行调试</para>
        /// </summary>
        [Key(5)]
        public int WebApiPort { get; set; }

        /// <summary>
        /// 视频流端口 (ZeroMQ Publisher/Push)
        /// </summary>
        [Key(6)]
        public int VideoPort { get; set; }

        /// <summary>
        /// 指令流端口 (ZeroMQ Response)
        /// </summary>
        [Key(7)]
        public int CmdPort { get; set; }

        #endregion

        #region --- 3. 运行时状态 ---

        /// <summary>
        /// 启动时间
        /// </summary>
        [Key(8)]
        public DateTime StartTime { get; set; }

        /// <summary>
        /// 描述信息 (可选)
        /// </summary>
        [Key(9)]
        public string Description { get; set; }

        #endregion
    }
}