Beispiel #1
0
        internal void ReadMail(ulong userGuid, ulong mailGuid)
        {
            DataProcessScheduler dataProcess = LobbyServer.Instance.DataProcessScheduler;
            UserInfo             user        = dataProcess.GetUserInfo(userGuid);

            if (null != user)
            {
                List <MailInfo> mails;
                if (m_UserMails.TryGetValue(userGuid, out mails))
                {
                    if (null != mails)
                    {
                        int ct    = mails.Count;
                        int index = 0;
                        for (; index < ct; ++index)
                        {
                            if (mails[index].m_MailGuid == mailGuid)
                            {
                                MailInfo info = mails[index];
                                info.m_AlreadyRead = true;
                                break;
                            }
                        }
                    }
                }
                MailStateInfo mailStateInfo = user.MailStateInfo;
                int           wholeCt       = m_WholeMails.Count;
                for (int index = 0; index < wholeCt; ++index)
                {
                    MailInfo info = m_WholeMails[index];
                    if (info.m_MailGuid == mailGuid)
                    {
                        mailStateInfo.ReadMail(mailGuid);
                        break;
                    }
                }
                int moduleCt = m_ModuleMails.Count;
                for (int index = 0; index < moduleCt; ++index)
                {
                    ModuleMailInfo mailInfo = m_ModuleMails[index];
                    if (mailInfo.m_MailGuid == mailGuid)
                    {
                        mailStateInfo.ReadMail(mailGuid);
                        break;
                    }
                }
            }
        }
Beispiel #2
0
        internal bool HaveMail(ulong userGuid)
        {
            bool ret = false;
            DataProcessScheduler dataProcess = LobbyServer.Instance.DataProcessScheduler;
            UserInfo             user        = dataProcess.GetUserInfo(userGuid);

            if (null != user)
            {
                List <MailInfo> userMails;
                if (m_UserMails.TryGetValue(userGuid, out userMails) && userMails.Count > 0)
                {
                    ret = true;
                }
                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))
                    {
                        ret = true;
                        break;
                    }
                }
                int moduleMailCt = m_ModuleMails.Count;
                for (int ix = 0; ix < moduleMailCt; ++ix)
                {
                    ModuleMailInfo     mailInfo = m_ModuleMails[ix];
                    IModuleMailHandler handler  = GetModuleMailHandler(mailInfo.m_Module);
                    if (null != handler)
                    {
                        if (handler.HaveMail(mailInfo, user))
                        {
                            ret = true;
                            break;
                        }
                    }
                }
            }
            return(ret);
        }
Beispiel #3
0
        internal void ReceiveMail(ulong userGuid, ulong mailGuid)
        {
            DataProcessScheduler dataProcess = LobbyServer.Instance.DataProcessScheduler;
            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)
                        {
                            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)
                        {
                            mailStateInfo.ReceiveMail(mailGuid);
                            if (info.m_LevelDemand <= user.Level && info.m_SendTime >= user.CreateTime && info.m_ExpiryDate >= DateTime.Now)
                            {
                                ExtractMailAttachment(info, userGuid);
                            }
                        }
                    }
                    int moduleCt = m_ModuleMails.Count;
                    for (int index = 0; index < moduleCt; ++index)
                    {
                        ModuleMailInfo mailInfo = m_ModuleMails[index];
                        if (mailInfo.m_MailGuid == mailGuid)
                        {
                            mailStateInfo.ReceiveMail(mailGuid);
                            if (mailInfo.m_SendTime >= user.CreateTime && mailInfo.m_ExpiryDate >= DateTime.Now)
                            {
                                IModuleMailHandler handler = GetModuleMailHandler(mailInfo.m_Module);
                                if (null != handler)
                                {
                                    MailInfo info = handler.GetMail(mailInfo, user, true);
                                    if (null != info)
                                    {
                                        ExtractMailAttachment(info, userGuid);
                                    }
                                }
                            }
                            break;
                        }
                    }
                }
            }
        }
Beispiel #4
0
        internal void GetMailList(ulong userGuid)
        {
            DataProcessScheduler dataProcess = LobbyServer.Instance.DataProcessScheduler;
            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_Module      = (int)mailInfo.m_Module;
                            mailInfoForMsg.m_Title       = mailInfo.m_Title;
                            mailInfoForMsg.m_Sender      = mailInfo.m_Sender;
                            mailInfoForMsg.m_SendTime    = mailInfo.m_SendTime;
                            mailInfoForMsg.m_Text        = mailInfo.m_Text;
                            mailInfoForMsg.m_Money       = mailInfo.m_Money;
                            mailInfoForMsg.m_Gold        = mailInfo.m_Gold;
                            mailInfoForMsg.m_Stamina     = mailInfo.m_Stamina;
                            int itemCt = mailInfo.m_Items.Count;
                            if (itemCt > 0)
                            {
                                mailInfoForMsg.m_Items = new MailItemForMessage[itemCt];
                                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[index] = 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_Module      = (int)mailInfo.m_Module;
                        mailInfoForMsg.m_Title       = mailInfo.m_Title;
                        mailInfoForMsg.m_Sender      = mailInfo.m_Sender;
                        mailInfoForMsg.m_SendTime    = mailInfo.m_SendTime;
                        mailInfoForMsg.m_Text        = mailInfo.m_Text;
                        mailInfoForMsg.m_Money       = mailInfo.m_Money;
                        mailInfoForMsg.m_Gold        = mailInfo.m_Gold;
                        mailInfoForMsg.m_Stamina     = mailInfo.m_Stamina;
                        int itemCt = mailInfo.m_Items.Count;
                        if (itemCt > 0)
                        {
                            mailInfoForMsg.m_Items = new MailItemForMessage[itemCt];
                            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[index] = mailItem;
                            }
                        }
                        mailList.Add(mailInfoForMsg);
                    }
                }
                int moduleMailCt = m_ModuleMails.Count;
                for (int ix = 0; ix < moduleMailCt; ++ix)
                {
                    ModuleMailInfo moduleMailInfo = m_ModuleMails[ix];
                    if (moduleMailInfo.m_SendTime >= user.CreateTime && moduleMailInfo.m_ExpiryDate >= DateTime.Now && !mailStateInfo.IsAlreadyReceived(moduleMailInfo.m_MailGuid))
                    {
                        if (!mailStateInfo.HaveMail(moduleMailInfo.m_MailGuid))
                        {
                            mailStateInfo.AddMail(moduleMailInfo.m_MailGuid, moduleMailInfo.m_ExpiryDate);
                        }
                        IModuleMailHandler handler = GetModuleMailHandler(moduleMailInfo.m_Module);
                        if (null != handler)
                        {
                            MailInfo mailInfo = handler.GetMail(moduleMailInfo, user, false);
                            if (null != mailInfo)
                            {
                                MailInfoForMessage mailInfoForMsg = new MailInfoForMessage();
                                mailInfoForMsg.m_AlreadyRead = mailStateInfo.IsAlreadyRead(moduleMailInfo.m_MailGuid);
                                mailInfoForMsg.m_MailGuid    = mailInfo.m_MailGuid;
                                mailInfoForMsg.m_Module      = (int)mailInfo.m_Module;
                                mailInfoForMsg.m_Title       = mailInfo.m_Title;
                                mailInfoForMsg.m_Sender      = mailInfo.m_Sender;
                                mailInfoForMsg.m_SendTime    = mailInfo.m_SendTime;
                                mailInfoForMsg.m_Text        = mailInfo.m_Text;
                                mailInfoForMsg.m_Money       = mailInfo.m_Money;
                                mailInfoForMsg.m_Gold        = mailInfo.m_Gold;
                                mailInfoForMsg.m_Stamina     = mailInfo.m_Stamina;
                                int itemCt = mailInfo.m_Items.Count;
                                if (itemCt > 0)
                                {
                                    mailInfoForMsg.m_Items = new MailItemForMessage[itemCt];
                                    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[index] = mailItem;
                                    }
                                }
                                mailList.Add(mailInfoForMsg);
                            }
                        }
                    }
                }
                JsonMessageSyncMailList syncMailListMsg = new JsonMessageSyncMailList();
                syncMailListMsg.m_Guid  = userGuid;
                syncMailListMsg.m_Mails = mailList.ToArray();
                JsonMessageDispatcher.SendDcoreMessage(user.NodeName, syncMailListMsg);
            }
        }