Example #1
0
        internal void Tick()
        {
            var ds_thread = LobbyServer.Instance.DataStoreThread;

            if (ds_thread.DataStoreAvailable)
            {
                if (!m_IsDataLoaded)
                {
                    return;
                }
            }
            long curTime = ArkCrossEngine.TimeUtility.GetServerMilliseconds();

            if (m_LastTickTime + c_TickInterval < curTime)
            {
                m_LastTickTime = curTime;
                //清理过期邮件
                int ct = m_WholeMails.Count;
                for (int index = ct - 1; index >= 0; --index)
                {
                    MailInfo mailInfo = m_WholeMails[index];
                    if (null != mailInfo)
                    {
                        if (mailInfo.m_ExpiryDate < DateTime.Now)
                        {
                            m_WholeMails.RemoveAt(index);
                        }
                    }
                }
                int count = m_ModuleMails.Count;
                for (int index = count - 1; index >= 0; --index)
                {
                    ModuleMailInfo moduleMail = m_ModuleMails[index];
                    if (null != moduleMail)
                    {
                        if (moduleMail.m_ExpiryDate < DateTime.Now)
                        {
                            m_ModuleMails.RemoveAt(index);
                        }
                    }
                }
                foreach (List <MailInfo> mails in m_UserMails.Values)
                {
                    int mailCt = mails.Count;
                    for (int index = mailCt - 1; index >= 0; --index)
                    {
                        MailInfo mailInfo = mails[index];
                        if (null != mailInfo)
                        {
                            if (mailInfo.m_ExpiryDate < DateTime.Now)
                            {
                                mails.RemoveAt(index);
                            }
                        }
                    }
                }
            }
        }
Example #2
0
        internal MailInfo NewDerivedMailInfo()
        {
            MailInfo mailInfo = new MailInfo();

            mailInfo.m_MailGuid   = m_MailGuid;
            mailInfo.m_Module     = m_Module;
            mailInfo.m_SendTime   = m_SendTime;
            mailInfo.m_ExpiryDate = m_ExpiryDate;
            return(mailInfo);
        }
Example #3
0
        private void ExtractMailAttachment(MailInfo info, ulong userGuid)
        {
            DataProcessScheduler dataProcess = LobbyServer.Instance.DataProcessScheduler;

            dataProcess.DispatchAction(dataProcess.DoAddAssets, userGuid, info.m_Money, info.m_Gold, 0, info.m_Stamina, GainConsumePos.Mail.ToString());

            int itemCt = info.m_Items.Count;

            for (int itemIx = 0; itemIx < itemCt; ++itemIx)
            {
                MailItem item = info.m_Items[itemIx];
                dataProcess.DispatchAction(dataProcess.DoAddItem, userGuid, item.m_ItemId, item.m_ItemNum, GainConsumePos.Mail.ToString());
            }
        }
Example #4
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);
            JsonMessageNotifyNewMail newMailMsg  = new JsonMessageNotifyNewMail();
            DataProcessScheduler     dataProcess = LobbyServer.Instance.DataProcessScheduler;

            dataProcess.VisitUsers((UserInfo userInfo) =>
            {
                newMailMsg.m_Guid = userInfo.Guid;
                JsonMessageDispatcher.SendDcoreMessage(userInfo.NodeName, newMailMsg);
            });
        }
Example #5
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;
                    }
                }
            }
        }
Example #6
0
        public MailInfo GetMail(ModuleMailInfo moduleMailInfo, UserInfo user, bool onlyAttachment)
        {
            MailInfo mailInfo = null;

            mailInfo = moduleMailInfo.NewDerivedMailInfo();
            if (!onlyAttachment)
            {
                mailInfo.m_Title  = "$1$";
                mailInfo.m_Text   = "$2$";
                mailInfo.m_Sender = "$3$";
            }
            int      gowElo   = 0;
            DateTime sendDate = mailInfo.m_SendTime.Date;
            DateTime sendTime = new DateTime(sendDate.Year, sendDate.Month, sendDate.Day, m_PrizeTime.m_Hour, m_PrizeTime.m_Minute, m_PrizeTime.m_Second);
            long     key      = sendTime.ToBinary();
            SortedList <long, int> history = user.GowInfo.HistoryGowElos;

            foreach (long key0 in history.Keys)
            {
                if (key >= key0)
                {
                    gowElo = history[key0];
                    break;
                }
            }
            if (gowElo > 0)
            {
                GowPrizeConfig cfg = GowConfigProvider.Instance.FindGowPrizeConfig(user.GowInfo.RankId);
                if (null != cfg)
                {
                    mailInfo.m_Money = cfg.Money;
                    mailInfo.m_Gold  = cfg.Gold;
                    foreach (GowPrizeItem item_config in cfg.Items)
                    {
                        MailItem mail_item = new MailItem();
                        mail_item.m_ItemId  = item_config.ItemId;
                        mail_item.m_ItemNum = item_config.ItemNum;
                        mailInfo.m_Items.Add(mail_item);
                    }
                    return(mailInfo);
                }
            }
            return(null);
        }
Example #7
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);
        }
Example #8
0
        private void GiveReward(UserInfo user, ArkCrossEngine.PaymentRebateConfig config)
        {
            MailInfo mail_info = new MailInfo();

            mail_info.m_Title       = "充值返利";
            mail_info.m_Text        = "充值返利";
            mail_info.m_LevelDemand = 0;
            mail_info.m_Money       = config.Gold;
            mail_info.m_Gold        = config.Diamond;
            mail_info.m_Stamina     = 0;
            mail_info.m_Items       = new List <MailItem>();
            for (int i = 0; i < config.ItemCount; ++i)
            {
                MailItem mail_item = new MailItem();
                mail_item.m_ItemId  = config.ItemIdList[i];
                mail_item.m_ItemNum = config.ItemNumList[i];
                mail_info.m_Items.Add(mail_item);
            }
            mail_info.m_Receiver = user.Guid;
            m_MailSystem.SendUserMail(mail_info, 10);
        }
Example #9
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);
            DataProcessScheduler dataProcess = LobbyServer.Instance.DataProcessScheduler;
            UserInfo             user        = dataProcess.GetUserInfo(userMail.m_Receiver);

            if (null != user && user.CurrentState != UserState.DropOrOffline)
            {
                JsonMessageNotifyNewMail newMailMsg = new JsonMessageNotifyNewMail();
                newMailMsg.m_Guid = userMail.m_Receiver;
                JsonMessageDispatcher.SendDcoreMessage(user.NodeName, newMailMsg);
            }
        }
Example #10
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;
                        }
                    }
                }
            }
        }
Example #11
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);
            }
        }
Example #12
0
 internal void SendWholeMail(MailInfo wholeMail, int validityPeriod)
 {
     m_MailSystem.SendWholeMail(wholeMail, validityPeriod);
 }
Example #13
0
 internal void SendUserMail(MailInfo userMail, int validityPeriod)
 {
     m_MailSystem.SendUserMail(userMail, validityPeriod);
 }