protected override void Decode(IChannelHandlerContext context, IByteBuffer message, List <object> output)
        {
            using (var r = new ReadOnlyByteBufferStream(message, false).ToBinaryReader(false))
            {
                var opCode     = r.ReadUInt16();
                var isInternal = opCode >= 64000;
                var factory    = isInternal
                    ? RmiMessageFactory.Default
                    : _userMessageFactories.FirstOrDefault(userFactory => userFactory.ContainsOpCode(opCode));

                if (factory == null)
                {
#if DEBUG
                    throw new ProudBadOpCodeException(opCode, message.ToArray());
#else
                    throw new ProudException($"No {nameof(MessageFactory)} found for opcode {opCode}");
#endif
                }

                output.Add(factory.GetMessage(opCode, r));
            }
        }
        protected override void Decode(IChannelHandlerContext context, RecvContext message, List <object> output)
        {
            var buffer = message.Message as IByteBuffer;

            try
            {
                // Drop core messages
                if (buffer == null)
                {
                    return;
                }

                using (var r = new ReadOnlyByteBufferStream(buffer, false).ToBinaryReader(false))
                {
                    var opCode     = r.ReadUInt16();
                    var isInternal = opCode >= 64000;
                    var factory    = isInternal
                        ? RmiMessageFactory.Default
                        : _userMessageFactories.FirstOrDefault(userFactory => userFactory.ContainsOpCode(opCode));

                    if (factory == null)
                    {
#if DEBUG
                        throw new ProudBadOpCodeException(opCode, buffer.ToArray());
#else
                        throw new ProudException($"No {nameof(MessageFactory)} found for opcode {opCode}");
#endif
                    }

                    message.Message = factory.GetMessage(opCode, r);
                    output.Add(message);
                }
            }
            finally
            {
                buffer?.Release();
            }
        }