Actor_TransferHandler.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System;
  2. using System.Net;
  3. namespace ET.Server
  4. {
  5. [ActorMessageHandler]
  6. public class Actor_TransferHandler : AMActorLocationRpcHandler<Unit, Actor_TransferRequest, Actor_TransferResponse>
  7. {
  8. protected override async ETTask Run(Unit unit, Actor_TransferRequest request, Actor_TransferResponse response, Action reply)
  9. {
  10. //long unitId = unit.Id;
  11. //
  12. //// 先在location锁住unit的地址
  13. //await Game.Scene.GetComponent<LocationProxyComponent>().Lock(unitId, unit.InstanceId);
  14. //
  15. //// 删除unit,让其它进程发送过来的消息找不到actor,重发
  16. //Game.EventSystem.Remove(unitId);
  17. //
  18. //long instanceId = unit.InstanceId;
  19. //
  20. //int mapIndex = request.MapIndex;
  21. //
  22. //StartConfigComponent startConfigComponent = StartConfigComponent.Instance;
  23. //
  24. //// 传送到map
  25. //StartConfig mapConfig = startConfigComponent.MapConfigs[mapIndex];
  26. //IPEndPoint address = mapConfig.GetComponent<InnerConfig>().IPEndPoint;
  27. //Session session = Game.Scene.GetComponent<NetInnerComponent>().Get(address);
  28. //
  29. //// 只删除不disponse否则M2M_TrasferUnitRequest无法序列化Unit
  30. //Game.Scene.GetComponent<UnitComponent>().RemoveNoDispose(unitId);
  31. //M2M_TrasferUnitResponse m2m_TrasferUnitResponse = (M2M_TrasferUnitResponse)await session.Call(new M2M_TrasferUnitRequest() { Unit = unit });
  32. //unit.Dispose();
  33. //
  34. //// 解锁unit的地址,并且更新unit的instanceId
  35. //await Game.Scene.GetComponent<LocationProxyComponent>().UnLock(unitId, instanceId, m2m_TrasferUnitResponse.InstanceId);
  36. reply();
  37. await ETTask.CompletedTask;
  38. }
  39. }
  40. }