G2G_LockRequestHandler.cs 749 B

1234567891011121314151617181920212223242526272829303132
  1. using System;
  2. using Model;
  3. namespace Hotfix
  4. {
  5. [MessageHandler(AppType.Gate)]
  6. public class G2G_LockRequestHandler : AMRpcHandler<G2G_LockRequest, G2G_LockResponse>
  7. {
  8. protected override async void Run(Session session, G2G_LockRequest message, Action<G2G_LockResponse> reply)
  9. {
  10. G2G_LockResponse response = new G2G_LockResponse();
  11. try
  12. {
  13. Unit unit = Game.Scene.GetComponent<UnitComponent>().Get(message.Id);
  14. if (unit == null)
  15. {
  16. response.Error = ErrorCode.ERR_NotFoundUnit;
  17. reply(response);
  18. return;
  19. }
  20. await unit.GetComponent<MasterComponent>().Lock(NetworkHelper.ToIPEndPoint(message.Address));
  21. reply(response);
  22. }
  23. catch (Exception e)
  24. {
  25. ReplyError(response, e, reply);
  26. }
  27. }
  28. }
  29. }