using MessagePack;
using Server.Core;

namespace NetWorkMessage
{
    [Message(MessageOpcode.UserLoginData)]
    [MessagePackObject]
    public class UserLoginDataMessage : MessageObject,IMessage
    {
        /// <summary>
        /// 玩家UserId
        /// </summary>
        [Key(0)]
        public int UserId;

        /// <summary>
        /// 玩家所属平台
        /// </summary>
        [Key(1)]
        public int Plat;

        /// <summary>
        /// 是否是属于新用户
        /// </summary>
        [Key(2)]
        public bool IsNewUser;

        /// <summary>
        /// 玩家渠道
        /// </summary>
        [Key(3)]
        public string Channel;
        
        public static UserLoginDataMessage Create(int userId,int plat,bool isNewUser,string channel)
        {
            UserLoginDataMessage loginDataMessage = new UserLoginDataMessage();
            loginDataMessage.UserId = userId;
            loginDataMessage.Plat = plat;
            loginDataMessage.IsNewUser = isNewUser;
            loginDataMessage.Channel = channel ?? string.Empty;
            return loginDataMessage;
        }

        protected override void VDispose()
        {
            Channel = null;
        }
    }
}