/// <inheritdoc /> protected internal override void Encode(IChannelHandlerContext context, IAddressedEnvelope <T> message, List <object> output) { this.encoder.Encode(context, message.Content, output); if (output.Count != 1) { CThrowHelper.ThrowEncoderException_MustProduceOnlyOneMsg(this.encoder.GetType()); } var content = output[0] as IByteBuffer; if (content is null) { CThrowHelper.ThrowEncoderException_MustProduceOnlyByteBuf(this.encoder.GetType()); } // Replace the ByteBuf with a DatagramPacket. output[0] = new DatagramPacket(content, message.Sender, message.Recipient); }