Example #1
0
  @Override
  public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
    try {
      ByteBuf recvBuf = Unpooled.copiedBuffer((ByteBuf) msg);
      byte[] buf = new byte[recvBuf.capacity()];
      recvBuf.readBytes(buf);

      String request = new String(buf, CharsetUtil.UTF_8);
      System.out.println("받는 Data : " + request);

      broadCast(ctx, request);
    } finally {
      ReferenceCountUtil.release(msg);
    }
  }
Example #2
0
 @Override
 public int readBytes(GatheringByteChannel out, int length) throws IOException {
   return buf.readBytes(out, length);
 }
Example #3
0
 @Override
 public ByteBuf readBytes(OutputStream out, int length) throws IOException {
   buf.readBytes(out, length);
   return this;
 }
Example #4
0
 @Override
 public ByteBuf readBytes(ByteBuffer dst) {
   buf.readBytes(dst);
   return this;
 }
Example #5
0
 @Override
 public ByteBuf readBytes(byte[] dst, int dstIndex, int length) {
   buf.readBytes(dst, dstIndex, length);
   return this;
 }
Example #6
0
 @Override
 public ByteBuf readBytes(byte[] dst) {
   buf.readBytes(dst);
   return this;
 }
Example #7
0
 @Override
 public ByteBuf readBytes(ByteBuf dst, int length) {
   buf.readBytes(dst, length);
   return this;
 }
Example #8
0
 @Override
 public ByteBuf readBytes(int length) {
   return buf.readBytes(length);
 }
 @Test
 public void testEmptyBuffer() {
   ByteBuf b = freeLater(wrappedBuffer(new byte[] {1, 2}, new byte[] {3, 4}));
   b.readBytes(new byte[4]);
   b.readBytes(EMPTY_BYTES);
 }