using MessagePack;
#if Server
using Server.Core;
#else
using GameFramework;
#endif

namespace GameMessage
{
    [Message(MessageCode.ClientPackRequest)]
    [MessagePackObject]
    public class ClientPackRequest : MessageData
    {
        /// <summary>
        /// 包头
        /// </summary>
        [Key(0)] public byte[] Head;

        /// <summary>
        /// 包数据
        /// </summary>
        [Key(1)] public byte[] Data;

#if GameClient
        public static ClientPackRequest Create(byte[] head, byte[] data)
        {
            ClientPackRequest request = ReferencePool.Acquire<ClientPackRequest>();
            request.Head = head;
            request.Data = data;
            return request;
        }

        public override void Clear()
        {
            Head = null;
            Data = null;
        }
#endif
    }

    [Message(MessageCode.ClientPackResponse)]
    [MessagePackObject]
    public class ClientPackResponse : MessageData
    {
        /// <summary>
        /// 包头
        /// </summary>
        [Key(0)] public byte[] Head;

        /// <summary>
        /// 包数据
        /// </summary>
        [Key(1)] public byte[] Data;

#if Server
        public static ClientPackResponse Create(byte[] head, byte[] data)
        {
            ClientPackResponse response = ReferencePool.Fetch<ClientPackResponse>();
            response.Head = head;
            response.Data = data;
            return response;
        }

        public override void Dispose()
        {
            Head = null;
            Data = null;
            ReferencePool.Recycle(this);
        }
#endif
    }
}