@@ -0,0 +1,1195 @@
+package io.elssa.nn;%0A%0Aimport java.util.List;%0A%0Aimport io.netty.buffer.ByteBuf;%0Aimport io.netty.channel.ChannelHandlerContext;%0Aimport io.netty.handler.codec.ReplayingDecoder;%0A%0Apublic class MessageDecoder extends ReplayingDecoder%3CDecoderState%3E %7B%0A%0A    private int length;%0A%0A    public MessageDecoder() %7B%0A        super(DecoderState.READ_LENGTH);%0A    %7D%0A%0A    @Override%0A    protected void decode(%0A            ChannelHandlerContext ctx, ByteBuf buf, List%3CObject%3E out)%0A    throws Exception %7B%0A%0A    switch (state()) %7B%0A        case READ_LENGTH:%0A            length = buf.readInt();%0A            checkpoint(DecoderState.READ_CONTENT);%0A            /* Fall through to the next state; the entire message may be%0A             * available */%0A%0A        case READ_CONTENT:%0A            ByteBuf frame = buf.readBytes(length);%0A            checkpoint(DecoderState.READ_LENGTH);%0A            out.add(frame);%0A            break;%0A%0A        default:%0A            throw new Error(%22Unknown decoder state%22);%0A    %7D%0A    %7D%0A%0A    @Override%0A    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) %7B%0A        // Close the connection when an exception is raised.%0A        cause.printStackTrace();%0A        ctx.close();%0A    %7D%0A%7D%0A

Create a replaying decoder