123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- using System;
- using System.Collections.Generic;
- using ET;
- using GFGGame;
- namespace ET
- {
- public class NoticeSystemNoticeChanged : AMHandler<M2C_SystemNoticeChanged>
- {
- 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<M2C_SystemNoticeRemoved>
- {
- 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<bool> ReqSystemNoticeList()
- {
- N2C_GetSystemNoticeList response = null;
- Session session = null;
- try
- {
- AccountInfoComponent accountInfoComponent = GameGlobal.zoneScene.GetComponent<AccountInfoComponent>();
- session = GameGlobal.zoneScene.GetComponent<NetKcpComponent>().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<bool> ReqSystemNotice(int noticeId)
- {
- N2C_GetSystemNotice response = null;
- Session session = null;
- try
- {
- AccountInfoComponent accountInfoComponent = GameGlobal.zoneScene.GetComponent<AccountInfoComponent>();
- session = GameGlobal.zoneScene.GetComponent<NetKcpComponent>().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;
- }
- }
- }
|