Exemplo n.º 1
0
 @Override
 public void write(final ChannelHandlerContext ctx, Object msg, ChannelPromise promise)
     throws Exception {
   if (!(msg instanceof ByteBuf)) {
     promise.setFailure(new UnsupportedMessageTypeException(msg, ByteBuf.class));
     return;
   }
   pendingUnencryptedWrites.add(msg, promise);
 }
Exemplo n.º 2
0
 @Override
 public void flush(ChannelHandlerContext ctx) throws Exception {
   // Do not encrypt the first write request if this handler is
   // created with startTLS flag turned on.
   if (startTls && !sentFirstMessage) {
     sentFirstMessage = true;
     pendingUnencryptedWrites.removeAndWriteAll();
     ctx.flush();
     return;
   }
   if (pendingUnencryptedWrites.isEmpty()) {
     // It's important to NOT use a voidPromise here as the user
     // may want to add a ChannelFutureListener to the ChannelPromise later.
     //
     // See https://github.com/netty/netty/issues/3364
     pendingUnencryptedWrites.add(Unpooled.EMPTY_BUFFER, ctx.newPromise());
   }
   if (!handshakePromise.isDone()) {
     flushedBeforeHandshake = true;
   }
   wrap(ctx, false);
   ctx.flush();
 }