예제 #1
0
  private void broadCast(ChannelHandlerContext ctx, String request) {
    String response = ManageSql(request.split(DELIMITER));

    response += DELIMITER;
    System.out.println("보내는 Data : " + response);
    ctx.writeAndFlush(Unpooled.copiedBuffer(response, CharsetUtil.UTF_8));
  }
예제 #2
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);
    }
  }