using ETModel; namespace ETHotfix { public static class MessageHelper { public static void Broadcast(Unit unit, IActorMessage message) { var units = unit.Domain.GetComponent().GetAll(); if (units == null) return; foreach (Unit u in units) { UnitGateComponent unitGateComponent = u.GetComponent(); if (unitGateComponent.IsDisconnect) { continue; } SendActor(unitGateComponent.GateSessionActorId, message); } } /// /// 发送协议给ActorLocation /// /// 注册Actor的Id /// public static void SendToLocationActor(long id, IActorLocationMessage message) { ActorLocationSenderComponent.Instance.Send(id, message); } /// /// 发送协议给Actor /// /// 注册Actor的InstanceId /// public static void SendActor(long actorId, IActorMessage message) { ActorMessageSenderComponent.Instance.Send(actorId, message); } /// /// 发送RPC协议给Actor /// /// 注册Actor的InstanceId /// /// public static async ETTask CallActor(long actorId, IActorRequest message) { return await ActorMessageSenderComponent.Instance.Call(actorId, message); } /// /// 发送RPC协议给ActorLocation /// /// 注册Actor的Id /// /// public static async ETTask CallLocationActor(long id, IActorLocationRequest message) { return await ActorLocationSenderComponent.Instance.Call(id, message); } } }