using MessagePack;
using Server.Core;

namespace NetWorkMessage
{
    /// <summary>
    /// 路由连接消息
    /// </summary>
    [Message(MessageOpcode.RouterSyn)]
    [MessagePackObject]
    public class RouterSynMessage : RouterMessage
    {
        /// <summary>
        /// IP地址
        /// </summary>
        [Key(0)]
        public string RemoteIpAddress;
        
        public static RouterSynMessage Create(string remoteIpAddress)
        {
            RouterSynMessage routerSynMessage = ReferencePool.Fetch<RouterSynMessage>();
            routerSynMessage.RemoteIpAddress = remoteIpAddress;
            return routerSynMessage;
        }
    }
    
    /// <summary>
    /// 路由确认消息
    /// </summary>
    [Message(MessageOpcode.RouterAck)]
    [MessagePackObject]
    public class RouterAckMessage : RouterMessage
    {
        public static RouterAckMessage Create()
        {
            RouterAckMessage routerAckMessage = ReferencePool.Fetch<RouterAckMessage>();
            return routerAckMessage;
        }
    }
    
    /// <summary>
    /// 路由结束消息
    /// </summary>
    [Message(MessageOpcode.RouterFin)]
    [MessagePackObject]
    public class RouterFinMessage : RouterMessage
    {
        public static RouterFinMessage Create()
        {
            RouterFinMessage routerFinMessage = ReferencePool.Fetch<RouterFinMessage>();
            return routerFinMessage;
        }
    }
    
    /// <summary>
    /// 路由结束确认消息
    /// </summary>
    [Message(MessageOpcode.RouterFinAck)]
    [MessagePackObject]
    public class RouterFinAckMessage : RouterMessage
    {
        /// <summary>
        /// 断开吗
        /// </summary>
        [Key(0)]
        public int FinCode;
        
        public static RouterFinAckMessage Create(int finCode)
        {
            RouterFinAckMessage routerFinAckMessage = ReferencePool.Fetch<RouterFinAckMessage>();
            routerFinAckMessage.FinCode = finCode;
            return routerFinAckMessage;
        }
    }
}