C2G_PingHandler.cs 608 B

12345678910111213141516171819202122
  1. using System;
  2. namespace ET.Server
  3. {
  4. /// <summary>
  5. /// 心跳消息
  6. /// </summary>
  7. [MessageHandler(SceneType.Game)]
  8. public class C2G_PingHandler : AMRpcHandler<C2G_Ping, G2C_Ping>
  9. {
  10. protected override async ETTask Run(Session session, C2G_Ping request, G2C_Ping response, Action reply)
  11. {
  12. if (session.GetComponent<HeartBeatComponent>() != null)
  13. {
  14. session.GetComponent<HeartBeatComponent>().CurrentTime = TimeHelper.ClientNowSeconds();
  15. }
  16. response.Time = TimeHelper.ServerNow();
  17. reply();
  18. await ETTask.CompletedTask;
  19. }
  20. }
  21. }