NoticeSProxy.cs 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 message)
  10. {
  11. NoticeDataManager.Instance.UpdateSystemNoticeChanged(message.NoticeId, message.Remove);
  12. await ETTask.CompletedTask;
  13. }
  14. }
  15. }
  16. namespace GFGGame
  17. {
  18. public static class NoticeSProxy
  19. {
  20. public static async ETTask<bool> ReqSystemNoticeList()
  21. {
  22. N2C_GetSystemNoticeList response = null;
  23. Session session = null;
  24. try
  25. {
  26. session = GameGlobal.zoneScene.GetComponent<NetKcpComponent>().Create(NetworkHelper.ToIPEndPoint(GameGlobal.noticeAddress));
  27. response = (N2C_GetSystemNoticeList)await session.Call(new C2N_GetSystemNoticeList() { });
  28. }
  29. catch (Exception e)
  30. {
  31. Log.Error(e.ToString());
  32. return false;
  33. }
  34. finally
  35. {
  36. session?.Dispose();
  37. }
  38. if (response.Error != ErrorCode.ERR_Success)
  39. {
  40. return false;
  41. }
  42. List<NoticeInfo> noticeInfos = new List<NoticeInfo>();
  43. for (int i = 0; i < response.NoticeIdList.Count; i++)
  44. {
  45. NoticeInfo noticeInfo = new NoticeInfo();
  46. noticeInfos.Add(noticeInfo);
  47. }
  48. // NoticeDataManager.Instance.UpdateNoticeIdList(noticeInfos);
  49. return true;
  50. }
  51. public static async ETTask<bool> ReqSystemNotice(int noticeId)
  52. {
  53. N2C_GetSystemNotice response = null;
  54. Session session = null;
  55. try
  56. {
  57. session = GameGlobal.zoneScene.GetComponent<NetKcpComponent>().Create(NetworkHelper.ToIPEndPoint(GameGlobal.noticeAddress));
  58. response = (N2C_GetSystemNotice)await session.Call(new C2N_GetSystemNotice() { NoticeId = noticeId });
  59. }
  60. catch (Exception e)
  61. {
  62. Log.Error(e.ToString());
  63. return false;
  64. }
  65. finally
  66. {
  67. session?.Dispose();
  68. }
  69. if (response.Error != ErrorCode.ERR_Success)
  70. {
  71. return false;
  72. }
  73. NoticeDataManager.Instance.noticeInfo.noticeId = response.NoticeId;
  74. NoticeDataManager.Instance.noticeInfo.title = response.Title;
  75. NoticeDataManager.Instance.noticeInfo.time = response.TimeSec;
  76. NoticeDataManager.Instance.noticeInfo.context = response.Content;
  77. return true;
  78. }
  79. }
  80. }