private void HandleBinaryWebSocketFrame(BinaryWebSocketFrame binaryWebSocketFrame, AppSession appSession) { var byteBuffer = binaryWebSocketFrame.Content; var readBytes = new byte[byteBuffer.ReadableBytes]; byteBuffer.ReadBytes(readBytes); var message = _packetCodec.Decode(readBytes); var requestContext = new RequestContext() { AppSession = appSession, Request = message }; var commandDescriptor = _commandContainer.Get(message.Command); if (commandDescriptor != null) { var commandContext = new CommandContext(commandDescriptor, _serviceProvider); if (!(_commandActivator.Create(commandContext) is ICommand command)) { throw new NotImplementedException(); } command.Execute(requestContext); } else { _logger.LogWarning($"The msg' command {byteBuffer} was not found."); } }
public virtual void Route(RequestContext requestContext) { Contract.Requires(requestContext != null); var passthroughRule = _passthroughRuleProvider.Create(requestContext); if (passthroughRule.IsPassThrough) { } else { try { var commandDescriptor = this._commandContainer.Get(requestContext.Request.Command); if (commandDescriptor != null) { var commandContext = new CommandContext(commandDescriptor, _serviceProvider); if ((_commandActivator.Create(commandContext) is ICommand command)) { command.Execute(requestContext); } } else { _logger.LogWarning($"The msg' command {requestContext.Request.Command} was not found."); } } catch (Exception ex) { _logger.LogError($"The msg' command {requestContext.Request.Command} catch an error {ex}."); } } }
public override void Route(RequestContext requestContext) { Contract.Requires(requestContext != null); var commandDescriptor = this._commandContainer.Get(requestContext.Request.Command); if (commandDescriptor != null) { var commandContext = new CommandContext(commandDescriptor, _serviceProvider); if (!(_commandActivator.Create(commandContext) is ICommand command)) { throw new NotImplementedException(nameof(commandContext)); } command.Execute(requestContext); } else { _logger.LogWarning($"The msg' command {requestContext.Request.Command} was not found."); } }