NoticeSProxy.cs 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. using System;
  2. using System.Collections.Generic;
  3. using ET;
  4. using GFGGame;
  5. namespace ET
  6. {
  7. public class NoticeSystemNoticeChanged : AMHandler<M2C_SystemNoticeChanged>
  8. {
  9. protected override async ETTask Run(Session session, M2C_SystemNoticeChanged response)
  10. {
  11. NoticeInfo noticeInfo = new NoticeInfo();
  12. noticeInfo.noticeId = response.Notice.NoticeId;
  13. noticeInfo.title = response.Notice.Title;
  14. noticeInfo.time = response.Notice.TimeSec;
  15. noticeInfo.readStatus = response.Notice.ReadStatus;
  16. noticeInfo.content = "";
  17. NoticeDataManager.Instance.UpdateNoticeIdList(noticeInfo);
  18. EventAgent.DispatchEvent(ConstMessage.NOTICE_SYSTOM_ADD);
  19. await ETTask.CompletedTask;
  20. }
  21. }
  22. public class NoticeSystemNoticeRemove : AMHandler<M2C_SystemNoticeRemoved>
  23. {
  24. protected override async ETTask Run(Session session, M2C_SystemNoticeRemoved response)
  25. {
  26. NoticeDataManager.Instance.UpdateSystemNoticeRemove(response.NoticeId);
  27. EventAgent.DispatchEvent(ConstMessage.NOTICE_SYSTOM_REMOVE);
  28. await ETTask.CompletedTask;
  29. }
  30. }
  31. }
  32. namespace GFGGame
  33. {
  34. public static class NoticeSProxy
  35. {
  36. public static async ETTask<bool> ReqSystemNoticeList()
  37. {
  38. M2C_GetSystemNoticeList response = null;
  39. response = (M2C_GetSystemNoticeList)await MessageHelper.SendToServer(new C2M_GetSystemNoticeList());
  40. if (response != null)
  41. {
  42. if (response.Error == ErrorCode.ERR_Success)
  43. {
  44. for (int i = 0; i < response.NoticeList.Count; i++)
  45. {
  46. NoticeInfo noticeInfo = new NoticeInfo();
  47. noticeInfo.noticeId = response.NoticeList[i].NoticeId;
  48. noticeInfo.title = response.NoticeList[i].Title;
  49. noticeInfo.time = response.NoticeList[i].TimeSec;
  50. noticeInfo.readStatus = response.NoticeList[i].ReadStatus;
  51. NoticeDataManager.Instance.UpdateNoticeIdList(noticeInfo);
  52. }
  53. return true;
  54. }
  55. }
  56. return false;
  57. }
  58. public static async ETTask<bool> ReqSystemNotice(int noticeId)
  59. {
  60. M2C_GetSystemNotice response = null;
  61. response = (M2C_GetSystemNotice)await MessageHelper.SendToServer(new C2M_GetSystemNotice() { NoticeId = noticeId });
  62. if (response != null)
  63. {
  64. if (response.Error == ErrorCode.ERR_Success)
  65. {
  66. NoticeDataManager.Instance.UpdateNoticeContent(response.NoticeId, response.Content);
  67. return true;
  68. }
  69. }
  70. return false;
  71. }
  72. }
  73. }