using System; using System.Threading.Tasks; using Common.Network; using Model; namespace Controller { [Event(EventType.LogicRecvRequestMessage, ServerType.All)] public class LogicRecvRequestMessageEvent : IEventAsync { public async Task RunAsync(Env env) { byte[] messageBytes = env.Get(EnvKey.MessageBytes); AChannel channel = env.Get(EnvKey.Channel); ushort opcode = env.Get(EnvKey.Opcode); MessageParseHelper.LogicParseRpcRequestMessage(messageBytes, env); try { await World.Instance.GetComponent().RunAsync(opcode, env); } catch (Exception e) { int requestId = env.Get(EnvKey.RpcRequestId); World.Instance.GetComponent().RpcException(channel, requestId, e); throw; } } } }