package com.bonus.tcp.util;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;

import java.util.List;

public class HexDecoder extends ByteToMessageDecoder {
    @Override
    protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
        ByteBuf buffer = ctx.alloc().buffer();
        while (in.isReadable()) {
            byte b = in.readByte();
            buffer.writeBytes(new byte[]{b});
        }
        out.add(buffer);
    }
}

