using System; using System.Collections.Generic; using ET; using GFGGame; namespace ET { public class NoticeSystemNoticeChanged : AMHandler { protected override async ETTask Run(Session session, M2C_SystemNoticeChanged response) { NoticeInfo noticeInfo = new NoticeInfo(); noticeInfo.noticeId = response.Notice.NoticeId; noticeInfo.title = response.Notice.Title; noticeInfo.time = response.Notice.TimeSec; noticeInfo.readStatus = response.Notice.ReadStatus; NoticeDataManager.Instance.UpdateNoticeIdList(noticeInfo); await ETTask.CompletedTask; } } public class NoticeSystemNoticeRemove : AMHandler { protected override async ETTask Run(Session session, M2C_SystemNoticeRemoved response) { NoticeDataManager.Instance.UpdateSystemNoticeRemove(response.NoticeId); await ETTask.CompletedTask; } } } namespace GFGGame { public static class NoticeSProxy { public static async ETTask ReqSystemNoticeList() { N2C_GetSystemNoticeList response = null; Session session = null; try { AccountInfoComponent accountInfoComponent = GameGlobal.zoneScene.GetComponent(); session = GameGlobal.zoneScene.GetComponent().Create(NetworkHelper.ToIPEndPoint(accountInfoComponent.NoticeAddress)); response = (N2C_GetSystemNoticeList)await session.Call(new C2N_GetSystemNoticeList() { AccountId = (int)accountInfoComponent.AccountId }); } catch (Exception e) { Log.Error(e.ToString()); return false; } finally { session?.Dispose(); } if (response.Error != ErrorCode.ERR_Success) { return false; } for (int i = 0; i < response.NoticeList.Count; i++) { NoticeInfo noticeInfo = new NoticeInfo(); noticeInfo.noticeId = response.NoticeList[i].NoticeId; noticeInfo.title = response.NoticeList[i].Title; noticeInfo.time = response.NoticeList[i].TimeSec; NoticeDataManager.Instance.UpdateNoticeIdList(noticeInfo); } return true; } public static async ETTask ReqSystemNotice(int noticeId) { N2C_GetSystemNotice response = null; Session session = null; try { AccountInfoComponent accountInfoComponent = GameGlobal.zoneScene.GetComponent(); session = GameGlobal.zoneScene.GetComponent().Create(NetworkHelper.ToIPEndPoint(accountInfoComponent.NoticeAddress)); response = (N2C_GetSystemNotice)await session.Call(new C2N_GetSystemNotice() { NoticeId = noticeId }); } catch (Exception e) { Log.Error(e.ToString()); return false; } finally { session?.Dispose(); } if (response.Error != ErrorCode.ERR_Success) { return false; } NoticeDataManager.Instance.UpdateNoticeContent(response.NoticeId, response.Content); return true; } } }