GateRecvClientMessageEvent.cs 797 B

1234567891011121314151617181920212223
  1. using Common.Network;
  2. using Model;
  3. namespace Controller
  4. {
  5. [Event(EventType.GateRecvClientMessage, ServerType.Gate)]
  6. public class GateRecvClientMessageEvent: IEventSync
  7. {
  8. public void Run(Env env)
  9. {
  10. byte[] messageBytes = env.Get<byte[]>(EnvKey.MessageBytes);
  11. AChannel channel = env.Get<AChannel>(EnvKey.Channel);
  12. // 进行消息分发
  13. ChannelUnitInfoComponent channelUnitInfoComponent =
  14. channel.GetComponent<ChannelUnitInfoComponent>();
  15. byte[] bytes = MessageParseHelper.ClientToGateMessageChangeToLogicMessage(messageBytes,
  16. channelUnitInfoComponent.UnitId);
  17. string address = AddressHelper.GetAddressByServerName(channelUnitInfoComponent.ServerName);
  18. World.Instance.GetComponent<NetworkComponent>().SendAsync(address, bytes);
  19. }
  20. }
  21. }