G2G_LockRequestHandler.cs 708 B

12345678910111213141516171819202122232425262728293031
  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. }
  19. await unit.GetComponent<MasterComponent>().Lock(message.Address);
  20. reply(response);
  21. }
  22. catch (Exception e)
  23. {
  24. ReplyError(response, e, reply);
  25. }
  26. }
  27. }
  28. }