NoticeSProxy.cs 3.0 KB

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