コード例 #1
0
 @SuppressWarnings("synthetic-access")
 @Override
 public void sessionClosed(IoSession session) throws Exception {
   TcpipClientChannel channel =
       (TcpipClientChannel) session.getAttribute(TcpipClientChannel.class);
   if (channel != null) {
     log.debug("IoSession {} closed, will now close the channel", session);
     channel.close(false);
   }
 }
コード例 #2
0
    @Override
    public void messageReceived(IoSession session, Readable message) throws Exception {
      TcpipClientChannel channel =
          (TcpipClientChannel) session.getAttribute(TcpipClientChannel.class);
      Buffer buffer = new ByteArrayBuffer();
      buffer.putBuffer(message);
      channel.waitFor(ClientChannel.OPENED | ClientChannel.CLOSED, Long.MAX_VALUE);

      OutputStream outputStream = channel.getInvertedIn();
      outputStream.write(buffer.array(), buffer.rpos(), buffer.available());
      outputStream.flush();
    }