G2G_LockRequestHandler.cs 720 B

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