Esempio n. 1
0
        public void SetMailNotNew(ulong mailId)
        {
            MailInfo mail = null;

            if (mMails.TryGetValue(mailId, out mail))
            {
                mail.IsNew = false;
            }
        }
Esempio n. 2
0
        public void ChangeMailState(uint state, ulong mailId)
        {
            MailInfo info = null;

            mMails.TryGetValue(mailId, out info);
            if (info != null)
            {
                info.netEmailInfo.state = state;
            }
        }
Esempio n. 3
0
        public void Delete(ulong mailId)
        {
            MailInfo willDeleteMail = GetMail(mailId);

            if (willDeleteMail == null)
            {
                return;
            }

            if (willDeleteMail.IsHaveAccessories() && willDeleteMail.IsGet == false)
            {
                //ShowAttachmentsTipsDialog(DBConstText.GetText("MAIL_ATTACHMENTS_DELETE"));
            }

            if (mMails.ContainsKey(mailId))
            {
                mMails.Remove(mailId);
            }
        }
Esempio n. 4
0
        public void AddMail(MailInfo info)
        {
            GameDebug.Log("AddMail");
            if (info == null)
            {
                return;
            }

            if (mMails.ContainsKey(info.MailId))
            {
                GameDebug.Log("MailManager2::AddMail error, the same mail key " + info.MailId + " is already exist.");
                GameDebug.Log("The added failed mail message is:" + info.Content);
                return;
            }

            mMails.Add(info.MailId, info);
//            xc.ClientEventManager<ClientEvent.FriendEvent>.Instance.FireEvent(ClientEvent.FriendEvent.RECEIVE_NEW_EMAIL_REQUEST, null);
            xc.ClientEventManager <ClientEvent> .Instance.FireEvent(ClientEvent.NEW_MAIL_RECEIVED, null);

            GameDebug.Log("AddMail add successed");
        }
Esempio n. 5
0
        int CompareMailInfo(MailInfo info1, MailInfo info2)
        {
            uint state1 = info1.netEmailInfo.state;
            uint state2 = info2.netEmailInfo.state;

            if (info1.IsHaveAccessoriesToGet() == true && info2.IsHaveAccessoriesToGet() == false)
            {
                return(-1);
            }
            else if (info2.IsHaveAccessoriesToGet() == true && info1.IsHaveAccessoriesToGet() == false)
            {
                return(1);
            }
            else
            {
                if (state1 == (uint)1 && state2 > (uint)1)
                {
                    return(-1);
                }
                else if (state1 > (uint)1 && state2 == (uint)1)
                {
                    return(1);
                }
                else
                {
                    if (info1.netEmailInfo.createtime > info2.netEmailInfo.createtime)
                    {
                        return(-1);
                    }
                    else if (info1.netEmailInfo.createtime < info2.netEmailInfo.createtime)
                    {
                        return(1);
                    }
                    return(0);
                }
            }
        }
Esempio n. 6
0
        private void HandleServerData(ushort protocol, byte[] data)
        {
            switch (protocol)
            {
            // 领取附件
            case NetMsg.MSG_GET_MAIL:
            {
                S2CGetMail mailGet  = S2CPackBase.DeserializePack <S2CGetMail>(data);
                MailInfo   mailInfo = MailManager2.Instance.GetMail(mailGet.mail_id);
                if (mailInfo != null)
                {
                    mailInfo.IsGet = true;
                    mailInfo.IsNew = false;
                }
                ClientEventMgr.GetInstance().FireEvent((int)ClientEvent.CE_MAIL_GET, new CEventBaseArgs(mailGet.mail_id));
                ClientEventMgr.Instance.FireEvent((int)ClientEvent.CE_MAIN_MAP_CHECK_MARK, new CEventBaseArgs((int)SysMarkType.FriendsAndMail));
                break;
            }

            // 全部的邮件列表
            case NetMsg.MSG_MAIL_LIST:
            {
                S2CMailList mailList = S2CPackBase.DeserializePack <S2CMailList>(data);
                if (mailList.mails == null)
                {
                    return;
                }

                foreach (var netMail in mailList.mails)
                {
                    MailInfo mailInfo = new MailInfo(netMail);
                    if (mailInfo.IsRead == false)
                    {
                        mailInfo.IsNew = true;
                    }
                    MailManager2.Instance.AddMail(mailInfo);
                }
                ClientEventMgr.GetInstance().FireEvent((int)ClientEvent.CE_MAIL_UPDATE, new CEventBaseArgs());
                ClientEventMgr.Instance.FireEvent((int)ClientEvent.CE_MAIN_MAP_CHECK_MARK, new CEventBaseArgs((int)SysMarkType.FriendsAndMail));

                MailManager2.Instance.UpdateRedPoint();
                break;
            }

            // 新邮件推送列表
            case NetMsg.MSG_NEW_MAIL:
            {
                S2CNewMail mailNew = S2CPackBase.DeserializePack <S2CNewMail>(data);
                if (mailNew.mails == null)
                {
                    return;
                }

                foreach (var netMail in mailNew.mails)
                {
                    MailInfo mailInfo = new MailInfo(netMail);
                    mailInfo.IsNew = true;
                    MailManager2.Instance.AddMail(mailInfo);
                }
                ClientEventMgr.GetInstance().FireEvent((int)ClientEvent.CE_MAIL_NEW, new CEventBaseArgs());
                ClientEventMgr.Instance.FireEvent((int)ClientEvent.CE_MAIN_MAP_CHECK_MARK, new CEventBaseArgs((int)SysMarkType.FriendsAndMail));

                MailManager2.Instance.UpdateRedPoint();
                break;
            }

            case NetMsg.MSG_READ_MAIL:
            {
                S2CReadMail mailNew  = S2CPackBase.DeserializePack <S2CReadMail>(data);
                MailInfo    mailInfo = MailManager2.Instance.GetMail(mailNew.mail_id);
                if (mailInfo != null)
                {
                    mailInfo.IsRead = true;
                    mailInfo.IsNew  = false;
                }
                ClientEventMgr.GetInstance().FireEvent((int)ClientEvent.CE_MAIL_READ, new CEventBaseArgs(mailNew.mail_id));
                ClientEventMgr.Instance.FireEvent((int)ClientEvent.CE_MAIN_MAP_CHECK_MARK, new CEventBaseArgs((int)SysMarkType.FriendsAndMail));

                MailManager2.Instance.UpdateRedPoint();
                break;
            }

            case NetMsg.MSG_MAIL_DEL:
            {
                S2CMailDel allMails = S2CPackBase.DeserializePack <S2CMailDel>(data);
                for (int i = 0; i < allMails.mail_ids.Count; i++)
                {
                    MailManager2.Instance.Delete(allMails.mail_ids[i]);
                }
                ClientEventMgr.GetInstance().FireEvent((int)ClientEvent.CE_MAIL_DEL, new CEventBaseArgs(allMails.mail_ids));
                ClientEventMgr.Instance.FireEvent((int)ClientEvent.CE_MAIN_MAP_CHECK_MARK, new CEventBaseArgs((int)SysMarkType.FriendsAndMail));

                MailManager2.Instance.UpdateRedPoint();
                break;
            }

            case NetMsg.MSG_MAIL_GET_ALL:
            {
                S2CMailGetAll allMails = S2CPackBase.DeserializePack <S2CMailGetAll>(data);
                for (int i = 0; i < allMails.mail_ids.Count; i++)
                {
                    MailInfo mailInfo = MailManager2.Instance.GetMail(allMails.mail_ids[i]);
                    if (mailInfo != null)
                    {
                        mailInfo.IsGet = true;
                        mailInfo.IsNew = false;
                    }

                    ClientEventMgr.GetInstance().FireEvent((int)ClientEvent.CE_MAIL_GET, new CEventBaseArgs(allMails.mail_ids[i]));
                }
                ClientEventMgr.Instance.FireEvent((int)ClientEvent.CE_MAIN_MAP_CHECK_MARK, new CEventBaseArgs((int)SysMarkType.FriendsAndMail));

                MailManager2.Instance.UpdateRedPoint();
                break;
            }

            case NetMsg.MSG_MAIL_DETAIL:
            {
                S2CMailDetail allMails = S2CPackBase.DeserializePack <S2CMailDetail>(data);
                MailInfo      mailInfo = MailManager2.Instance.GetMail(allMails.mail_id);
                if (mailInfo == null)
                {
                    return;
                }
                mailInfo.netEmailAttachs.Clear();
                foreach (var attach in allMails.attachments)
                {
                    mailInfo.netEmailAttachs.Add(attach);
                }
                mailInfo.LinkUrl   = allMails.link_url == null ? string.Empty:System.Text.Encoding.UTF8.GetString(allMails.link_url);
                mailInfo.LinkTitle = allMails.link_desc == null ? string.Empty:System.Text.Encoding.UTF8.GetString(allMails.link_desc);
                mailInfo.Content   = allMails.content == null ? string.Empty:System.Text.Encoding.UTF8.GetString(allMails.content);
                ClientEventMgr.GetInstance().FireEvent((int)ClientEvent.CE_MAIL_DETAIL, new CEventBaseArgs(mailInfo));
                break;
            }
            }
        }