MessageHelper.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using System.Collections.Generic;
  2. using System.IO;
  3. namespace ET.Server
  4. {
  5. public static class MessageHelper
  6. {
  7. public static void SendToClient(Player player, IActorMessage message)
  8. {
  9. SendActor(player.Id, message);
  10. }
  11. /// <summary>
  12. /// 发送协议给ActorLocation
  13. /// </summary>
  14. /// <param name="id">注册Actor的Id</param>
  15. /// <param name="message"></param>
  16. public static void SendToLocationActor(long id, IActorLocationMessage message)
  17. {
  18. ActorLocationSenderComponent.Instance.Send(id, message);
  19. }
  20. /// <summary>
  21. /// 发送协议给Actor
  22. /// </summary>
  23. /// <param name="actorId">注册Actor的InstanceId</param>
  24. /// <param name="message"></param>
  25. public static void SendActor(long actorId, IActorMessage message)
  26. {
  27. ActorMessageSenderComponent.Instance.Send(actorId, message);
  28. }
  29. /// <summary>
  30. /// 发送RPC协议给Actor
  31. /// </summary>
  32. /// <param name="actorId">注册Actor的InstanceId</param>
  33. /// <param name="message"></param>
  34. /// <returns></returns>
  35. public static async ETTask<IActorResponse> CallActor(long actorId, IActorRequest message)
  36. {
  37. return await ActorMessageSenderComponent.Instance.Call(actorId, message);
  38. }
  39. /// <summary>
  40. /// 发送RPC协议给ActorLocation
  41. /// </summary>
  42. /// <param name="id">注册Actor的Id</param>
  43. /// <param name="message"></param>
  44. /// <returns></returns>
  45. public static async ETTask<IActorResponse> CallLocationActor(long id, IActorLocationRequest message)
  46. {
  47. return await ActorLocationSenderComponent.Instance.Call(id, message);
  48. }
  49. }
  50. }