Ejemplo n.º 1
0
  private WriteFuture initiateClosure(NextFilter nextFilter, IoSession session)
      throws SSLException {
    SslHandler handler = getSslSessionHandler(session);
    // if already shut down
    if (!handler.closeOutbound()) {
      return DefaultWriteFuture.newNotWrittenFuture(
          session, new IllegalStateException("SSL session is shut down already."));
    }

    // there might be data to write out here?
    WriteFuture future = handler.writeNetBuffer(nextFilter);
    if (future == null) {
      future = DefaultWriteFuture.newWrittenFuture(session);
    }

    if (handler.isInboundDone()) {
      handler.destroy();
    }

    if (session.containsAttribute(USE_NOTIFICATION)) {
      handler.scheduleMessageReceived(nextFilter, SESSION_UNSECURED);
    }

    return future;
  }
Ejemplo n.º 2
0
    public WriteFuture flush() {
      Queue<Object> bufferQueue = getMessageQueue();
      WriteFuture future = null;
      for (; ; ) {
        Object encodedMessage = bufferQueue.poll();
        if (encodedMessage == null) {
          break;
        }

        // Flush only when the buffer has remaining.
        if (!(encodedMessage instanceof IoBuffer) || ((IoBuffer) encodedMessage).hasRemaining()) {
          future = new DefaultWriteFuture(session);
          nextFilter.filterWrite(
              session,
              new EncodedWriteRequest(encodedMessage, future, writeRequest.getDestination()));
        }
      }

      if (future == null) {
        future =
            DefaultWriteFuture.newNotWrittenFuture(
                session, new NothingWrittenException(writeRequest));
      }

      return future;
    }