Exemplo n.º 1
0
        private void ExtractMailAttachment(MailInfo info, ulong userGuid)
        {
            UserProcessScheduler dataProcess = UserServer.Instance.UserProcessScheduler;
            UserThread userThread = dataProcess.GetUserThread(userGuid);
            userThread.QueueAction(userThread.AddAssets, userGuid, info.m_Money, info.m_Gold);

            int itemCt = info.m_Items.Count;
            for (int itemIx = 0; itemIx < itemCt; ++itemIx) {
                MailItem item = info.m_Items[itemIx];
                userThread.QueueAction(userThread.AddItem, userGuid, item.m_ItemId, item.m_ItemNum);
            }
        }
Exemplo n.º 2
0
 internal void SendWholeMail(MailInfo wholeMail, int validityPeriod)
 {
     wholeMail.m_MailGuid = GenMailGuid();
     wholeMail.m_SendTime = DateTime.Now;
     wholeMail.m_ExpiryDate = wholeMail.m_SendTime.AddDays(validityPeriod);
     m_WholeMails.Add(wholeMail);
     NodeMessage newMailMsg = new NodeMessage(LobbyMessageDefine.Msg_LC_NotifyNewMail);
     NodeMessageWithGuid headerData = new NodeMessageWithGuid();
     newMailMsg.m_NodeHeader = headerData;
     UserProcessScheduler dataProcess = UserServer.Instance.UserProcessScheduler;
     dataProcess.VisitUsers((UserInfo userInfo) => {
         headerData.m_Guid = userInfo.Guid;
         NodeMessageDispatcher.SendNodeMessage(userInfo.NodeName, newMailMsg);
     });
 }
Exemplo n.º 3
0
 internal void SendUserMail(MailInfo userMail, int validityPeriod)
 {
     userMail.m_MailGuid = GenMailGuid();
     userMail.m_SendTime = DateTime.Now;
     userMail.m_ExpiryDate = userMail.m_SendTime.AddDays(validityPeriod);
     List<MailInfo> mails = null;
     if (!m_UserMails.TryGetValue(userMail.m_Receiver, out mails)) {
         mails = new List<MailInfo>();
         m_UserMails.Add(userMail.m_Receiver, mails);
     }
     mails.Add(userMail);
     UserProcessScheduler dataProcess = UserServer.Instance.UserProcessScheduler;
     UserInfo user = dataProcess.GetUserInfo(userMail.m_Receiver);
     if (null != user && user.CurrentState != UserState.DropOrOffline) {
         NodeMessage newMailMsg = new NodeMessage(LobbyMessageDefine.Msg_LC_NotifyNewMail, userMail.m_Receiver);
         NodeMessageDispatcher.SendNodeMessage(user.NodeName, newMailMsg);
     }
 }
Exemplo n.º 4
0
 internal void ReceiveMail(ulong userGuid, ulong mailGuid)
 {
     UserProcessScheduler dataProcess = UserServer.Instance.UserProcessScheduler;
     UserInfo user = dataProcess.GetUserInfo(userGuid);
     if (null != user) {
         List<MailInfo> mails;
         if (m_UserMails.TryGetValue(userGuid, out mails)) {
             if (null != mails) {
                 MailInfo info = null;
                 int ct = mails.Count;
                 int index = 0;
                 for (; index < ct; ++index) {
                     if (mails[index].m_MailGuid == mailGuid) {
                         info = mails[index];
                         break;
                     }
                 }
                 if (null != info && CheckBagCapacity(user, info)) {
                     mails.RemoveAt(index);
                     ExtractMailAttachment(info, userGuid);
                 }
             }
         }
         MailStateInfo mailStateInfo = user.MailStateInfo;
         if (!mailStateInfo.IsAlreadyReceived(mailGuid)) {
             int wholeCt = m_WholeMails.Count;
             for (int index = 0; index < wholeCt; ++index) {
                 MailInfo info = m_WholeMails[index];
                 if (info.m_MailGuid == mailGuid) {
                     if (CheckBagCapacity(user, info)) {
                         mailStateInfo.ReceiveMail(mailGuid);
                         if (info.m_LevelDemand <= user.Level && info.m_SendTime >= user.CreateTime && info.m_ExpiryDate >= DateTime.Now) {
                             ExtractMailAttachment(info, userGuid);
                         }
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 5
0
 private bool CheckBagCapacity(UserInfo user, MailInfo info)
 {
     bool result = true;
     if (null == user || null == user.ItemBag
       || null == info || null == info.m_Items) {
         return result;
     }
     int ct = info.m_Items.Count;
     int free = user.ItemBag.GetFreeCount();
     if (ct > free) {
         result = false;
     }
     NodeMessage opMsg = new NodeMessage(LobbyMessageDefine.Msg_LC_LackOfSpace, user.Guid);
     Msg_LC_LackOfSpace protoData = new Msg_LC_LackOfSpace();
     protoData.m_Succeed = result;
     protoData.m_ReceiveNum = ct;
     protoData.m_FreeNum = free;
     protoData.m_MailGuid = info.m_MailGuid;
     opMsg.m_ProtoData = protoData;
     NodeMessageDispatcher.SendNodeMessage(user.NodeName, opMsg);
     return result;
 }
        protected override bool ExecCommand(StoryInstance instance, long delta)
        {
            UserThread userThread = instance.Context as UserThread;
            if (null != userThread) {
                ulong receiver = m_Receiver.Value;
                string title = m_Title.Value;
                string content = m_Content.Value;
                string sender = m_Sender.Value;
                int levelDemand = m_LevelDemand.Value;
                int validPeriod = m_ValidPeriod.Value;
                int money = m_Money.Value;
                int gold = m_Gold.Value;

                MailInfo mailInfo = new MailInfo();
                mailInfo.m_Receiver = receiver;
                mailInfo.m_Title = title;
                mailInfo.m_Text = content;
                mailInfo.m_Sender = sender;
                mailInfo.m_Money = money;
                mailInfo.m_Gold = gold;
                mailInfo.m_LevelDemand = levelDemand;

                for (int i = 0; i < m_MailItems.Count - 1; i += 2) {
                    int itemId = m_MailItems[i].Value;
                    int itemNum = m_MailItems[i + 1].Value;

                    MailItem mailItem = new MailItem();
                    mailItem.m_ItemId = itemId;
                    mailItem.m_ItemNum = itemNum;
                    mailInfo.m_Items.Add(mailItem);
                }
                GlobalProcessThread globalProcess = UserServer.Instance.GlobalProcessThread;
                if (receiver > 0) {
                    globalProcess.QueueAction(globalProcess.SendUserMail, mailInfo, validPeriod);
                } else {
                    globalProcess.QueueAction(globalProcess.SendWholeMail, mailInfo, validPeriod);
                }
            }
            return false;
        }
 internal void SendWholeMail(MailInfo wholeMail, int validityPeriod)
 {
     m_MailSystem.SendWholeMail(wholeMail, validityPeriod);
 }
 internal void SendUserMail(MailInfo userMail, int validityPeriod)
 {
     m_MailSystem.SendUserMail(userMail, validityPeriod);
 }
Exemplo n.º 9
0
 internal void GetMailList(ulong userGuid)
 {
     UserProcessScheduler dataProcess = UserServer.Instance.UserProcessScheduler;
     UserInfo user = dataProcess.GetUserInfo(userGuid);
     if (null != user) {
         List<MailInfoForMessage> mailList = new List<MailInfoForMessage>();
         List<MailInfo> mails;
         if (m_UserMails.TryGetValue(userGuid, out mails)) {
             int ct = mails.Count;
             for (int ix = 0; ix < ct; ++ix) {
                 MailInfo mailInfo = mails[ix];
                 if (mailInfo.m_ExpiryDate >= DateTime.Now) {
                     MailInfoForMessage mailInfoForMsg = new MailInfoForMessage();
                     mailInfoForMsg.m_AlreadyRead = mailInfo.m_AlreadyRead;
                     mailInfoForMsg.m_MailGuid = mailInfo.m_MailGuid;
                     mailInfoForMsg.m_Title = mailInfo.m_Title;
                     mailInfoForMsg.m_Sender = mailInfo.m_Sender;
                     mailInfoForMsg.m_SendTime = mailInfo.m_SendTime.ToString("yyyyMMddHHmmss");
                     mailInfoForMsg.m_Text = mailInfo.m_Text;
                     mailInfoForMsg.m_Money = mailInfo.m_Money;
                     mailInfoForMsg.m_Gold = mailInfo.m_Gold;
                     int itemCt = mailInfo.m_Items.Count;
                     if (itemCt > 0) {
                         for (int index = 0; index < itemCt; ++index) {
                             MailItemForMessage mailItem = new MailItemForMessage();
                             mailItem.m_ItemId = mailInfo.m_Items[index].m_ItemId;
                             mailItem.m_ItemNum = mailInfo.m_Items[index].m_ItemNum;
                             mailInfoForMsg.m_Items.Add(mailItem);
                         }
                     }
                     mailList.Add(mailInfoForMsg);
                 }
             }
         }
         MailStateInfo mailStateInfo = user.MailStateInfo;
         //这里不对用户数据加锁,因为用户的邮件状态的改变都在这个线程完成(除上线时的数据加载)
         int wholeMailCt = m_WholeMails.Count;
         for (int ix = 0; ix < wholeMailCt; ++ix) {
             MailInfo mailInfo = m_WholeMails[ix];
             if (mailInfo.m_LevelDemand <= user.Level
               && mailInfo.m_SendTime >= user.CreateTime
               && mailInfo.m_ExpiryDate >= DateTime.Now
               && !mailStateInfo.IsAlreadyReceived(mailInfo.m_MailGuid)) {
                 if (!mailStateInfo.HaveMail(mailInfo.m_MailGuid)) {
                     mailStateInfo.AddMail(mailInfo.m_MailGuid, mailInfo.m_ExpiryDate);
                 }
                 MailInfoForMessage mailInfoForMsg = new MailInfoForMessage();
                 mailInfoForMsg.m_AlreadyRead = mailStateInfo.IsAlreadyRead(mailInfo.m_MailGuid);
                 mailInfoForMsg.m_MailGuid = mailInfo.m_MailGuid;
                 mailInfoForMsg.m_Title = mailInfo.m_Title;
                 mailInfoForMsg.m_Sender = mailInfo.m_Sender;
                 mailInfoForMsg.m_SendTime = mailInfo.m_SendTime.ToString("yyyyMMddHHmmss");
                 mailInfoForMsg.m_Text = mailInfo.m_Text;
                 mailInfoForMsg.m_Money = mailInfo.m_Money;
                 mailInfoForMsg.m_Gold = mailInfo.m_Gold;
                 int itemCt = mailInfo.m_Items.Count;
                 if (itemCt > 0) {
                     for (int index = 0; index < itemCt; ++index) {
                         MailItemForMessage mailItem = new MailItemForMessage();
                         mailItem.m_ItemId = mailInfo.m_Items[index].m_ItemId;
                         mailItem.m_ItemNum = mailInfo.m_Items[index].m_ItemNum;
                         mailInfoForMsg.m_Items.Add(mailItem);
                     }
                 }
                 mailList.Add(mailInfoForMsg);
             }
         }
         NodeMessage syncMailListMsg = new NodeMessage(LobbyMessageDefine.Msg_LC_SyncMailList, userGuid);
         GameFrameworkMessage.Msg_LC_SyncMailList protoMsg = new Msg_LC_SyncMailList();
         protoMsg.m_Mails.AddRange(mailList);
         syncMailListMsg.m_ProtoData = protoMsg;
         NodeMessageDispatcher.SendNodeMessage(user.NodeName, syncMailListMsg);
     }
 }
Exemplo n.º 10
0
 internal void SendWholeMail(MailInfo wholeMail, int validityPeriod)
 {
     m_MailSystem.SendWholeMail(wholeMail, validityPeriod);
 }
Exemplo n.º 11
0
 internal void SendUserMail(MailInfo userMail, int validityPeriod)
 {
     m_MailSystem.SendUserMail(userMail, validityPeriod);
 }
Exemplo n.º 12
0
        private void ExtractMailAttachment(MailInfo info, ulong userGuid)
        {
            UserProcessScheduler dataProcess = UserServer.Instance.UserProcessScheduler;
            UserThread userThread = dataProcess.GetUserThread(userGuid);
            userThread.QueueAction(userThread.AddAssets, userGuid, info.m_Money, info.m_Gold);

            int itemCt = info.m_Items.Count;
            for (int itemIx = 0; itemIx < itemCt; ++itemIx) {
                MailItem item = info.m_Items[itemIx];
                userThread.QueueAction(userThread.AddItem, userGuid, item.m_ItemId, item.m_ItemNum);
            }
        }
Exemplo n.º 13
0
 private bool CheckBagCapacity(UserInfo user, MailInfo info)
 {
     bool result = true;
     if (null == user || null == user.ItemBag
       || null == info || null == info.m_Items) {
         return result;
     }
     int ct = info.m_Items.Count;
     int free = user.ItemBag.GetFreeCount();
     if (ct > free) {
         result = false;
     }
     NodeMessage opMsg = new NodeMessage(LobbyMessageDefine.Msg_LC_LackOfSpace, user.Guid);
     Msg_LC_LackOfSpace protoData = new Msg_LC_LackOfSpace();
     protoData.m_Succeed = result;
     protoData.m_ReceiveNum = ct;
     protoData.m_FreeNum = free;
     protoData.m_MailGuid = info.m_MailGuid;
     opMsg.m_ProtoData = protoData;
     NodeMessageDispatcher.SendNodeMessage(user.NodeName, opMsg);
     return result;
 }
Exemplo n.º 14
0
 internal void SendWholeMail(MailInfo wholeMail, int validityPeriod)
 {
     wholeMail.m_MailGuid = GenMailGuid();
     wholeMail.m_SendTime = DateTime.Now;
     wholeMail.m_ExpiryDate = wholeMail.m_SendTime.AddDays(validityPeriod);
     m_WholeMails.Add(wholeMail);
     NodeMessage newMailMsg = new NodeMessage(LobbyMessageDefine.Msg_LC_NotifyNewMail);
     NodeMessageWithGuid headerData = new NodeMessageWithGuid();
     newMailMsg.m_NodeHeader = headerData;
     UserProcessScheduler dataProcess = UserServer.Instance.UserProcessScheduler;
     dataProcess.VisitUsers((UserInfo userInfo) => {
         headerData.m_Guid = userInfo.Guid;
         NodeMessageDispatcher.SendNodeMessage(userInfo.NodeName, newMailMsg);
     });
 }
Exemplo n.º 15
0
 internal void SendUserMail(MailInfo userMail, int validityPeriod)
 {
     userMail.m_MailGuid = GenMailGuid();
     userMail.m_SendTime = DateTime.Now;
     userMail.m_ExpiryDate = userMail.m_SendTime.AddDays(validityPeriod);
     List<MailInfo> mails = null;
     if (!m_UserMails.TryGetValue(userMail.m_Receiver, out mails)) {
         mails = new List<MailInfo>();
         m_UserMails.Add(userMail.m_Receiver, mails);
     }
     mails.Add(userMail);
     UserProcessScheduler dataProcess = UserServer.Instance.UserProcessScheduler;
     UserInfo user = dataProcess.GetUserInfo(userMail.m_Receiver);
     if (null != user && user.CurrentState != UserState.DropOrOffline) {
         NodeMessage newMailMsg = new NodeMessage(LobbyMessageDefine.Msg_LC_NotifyNewMail, userMail.m_Receiver);
         NodeMessageDispatcher.SendNodeMessage(user.NodeName, newMailMsg);
     }
 }