123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- 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 (message.Type == ChatType.Private)
- // {
- // if (!ChatDataManager.Instance.PrivateChatDatas.ContainsKey(chatData.TargetId))
- // {
- // ChatDataManager.Instance.PrivateChatDatas[chatData.TargetId] = new List<ChatData>();
- // }
- // ChatDataManager.Instance.PrivateChatDatas[chatData.TargetId].Add(chatData);
- // if (response.ChatMsgs[i].Type == ChatType.Private)
- // {
- // ChatDataManager.Instance.GetChatDatas(chatData.TargetId).Add(chatData);
- // }
- // else
- // {
- // ChatDataManager.Instance.GetChatDatas(chatData.Type).Add(chatData);
- // }
- // }
- // else
- // {
- // if (!ChatDataManager.Instance.PrivateChatDatas.ContainsKey(chatData.Type))
- // {
- // ChatDataManager.Instance.PrivateChatDatas[chatData.Type] = new List<ChatData>();
- // }
- // ChatDataManager.Instance.PrivateChatDatas[chatData.Type].Add(chatData);
- // }
- 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<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)
- {
- if (response.Error == ErrorCode.ERR_Success)
- {
- 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;
- }
- }
- }
|