using System.Collections.Generic; using ET; using GFGGame; namespace ET { public class NoticeNoticeChatMsg : AMHandler { 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); } EventAgent.DispatchEvent(ConstMessage.NOTICE_CHAT_MESSAGE); await ETTask.CompletedTask; } } } namespace GFGGame { public static class ChatSProxy { public static async ETTask 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 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; } } }