| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 | using System.Collections.Generic;using ET;using GFGGame;namespace ET{    public class NoticeNoticeChatMsg : AMHandler<S2C_NoticeChatMsg>    {        protected override async ETTask Run(Session session, S2C_NoticeChatMsg message)        {            ChatData chatData = new ChatData();            chatData.Type = message.Type;            chatData.RoleInfo = RoleDataManager.GetOtherRoleInfoData(message.RoleInfo);            chatData.TargetId = chatData.RoleInfo.roleId;            chatData.Content = message.Content;            chatData.Time = message.Time;            if (chatData.Type == ChatType.Private)            {                ChatDataManager.Instance.GetChatDatas(chatData.TargetId).Add(chatData);            }            else            {                ChatDataManager.Instance.GetChatDatas(chatData.Type).Add(chatData);            }            if (!ViewManager.isViewOpen(typeof(LeagueChatView).FullName))                 ChatDataManager.Instance.NewChatInfo = true;            EventAgent.DispatchEvent(ConstMessage.NOTICE_CHAT_MESSAGE);            await ETTask.CompletedTask;        }    }}namespace GFGGame{    public static class ChatSProxy    {        public static async ETTask<bool> ReqSendChatMsg(int type, string content, long targetId = 0)        {            S2C_SendChatMsg response = null;            response = (S2C_SendChatMsg)await MessageHelper.SendToServer(new C2S_SendChatMsg() { Type = type, Content = content, TargetId = targetId });            if (response != null)            {                // ChatData chatData = new ChatData();                // chatData.Type = type;                // chatData.RoleInfo = RoleDataManager.GetMineRoleInfoData();                // chatData.TargetId = targetId;                // chatData.Content = content;                // chatData.Time = TimeHelper.ServerNow();                if (response.Error == ErrorCode.ERR_Success)                {                    // if (type == ChatType.Private)                    // {                    //     ChatDataManager.Instance.GetChatDatas(targetId).Add(chatData);                    // }                    // else                    // {                    //     ChatDataManager.Instance.GetChatDatas(type).Add(chatData);                    // }                    return true;                }            }            return false;        }        public static async ETTask<bool> ReqQueryChatMsg(int type)        {            S2C_QueryChatMsg response = null;            response = (S2C_QueryChatMsg)await MessageHelper.SendToServer(new C2S_QueryChatMsg() { Type = type });            if (response != null)            {                if (response.Error == ErrorCode.ERR_Success)                {                    if (ChatDataManager.Instance.ChatDatas.ContainsKey(type))                    {                        ChatDataManager.Instance.ChatDatas[type].Clear();                    }                    for (int i = 0; i < response.ChatMsgs.Count; i++)                    {                        ChatData chatData = new ChatData();                        chatData.Type = response.ChatMsgs[i].Type;                        chatData.RoleInfo = RoleDataManager.GetOtherRoleInfoData(response.ChatMsgs[i].RoleInfo);                        chatData.TargetId = chatData.RoleInfo.roleId;                        chatData.Content = response.ChatMsgs[i].Content;                        chatData.Time = response.ChatMsgs[i].Time;                        if (response.ChatMsgs[i].Type == ChatType.Private)                        {                            ChatDataManager.Instance.GetChatDatas(chatData.TargetId).Add(chatData);                        }                        else                        {                            ChatDataManager.Instance.GetChatDatas(chatData.Type).Add(chatData);                        }                    }                    return true;                }            }            return false;        }    }}
 |