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."); } }
protected override object Decode(IChannelHandlerContext context, IByteBuffer input) { if (base.Decode(context, input) is IByteBuffer byteBuffer) { //var bodyLength = base.GetUnadjustedFrameLength(input, _packetCodec.LengthFieldOffset, _packetCodec.LengthFieldLength, _packetCodec.IsLittleEndian ? ByteOrder.LittleEndian : ByteOrder.BigEndian); var readBytes = new byte[byteBuffer.ReadableBytes]; byteBuffer.ReadBytes(readBytes); var message = _packetCodec.Decode(readBytes); return(message); } return(input); }