Ejemplo n.º 1
0
  @Override
  public void produceData(final IOSession iosession, final ClientState sessionState)
      throws IOException, SMTPProtocolException {
    Args.notNull(iosession, "IO session");
    Args.notNull(sessionState, "Session state");

    SessionOutputBuffer buf = this.iobuffers.getOutbuf();

    String myHelo = heloName;
    if (myHelo == null) {
      myHelo = AddressUtils.resolveLocalDomain(iosession.getLocalAddress());
    }
    switch (this.codecState) {
      case EHLO_READY:
        SMTPCommand ehlo = new SMTPCommand("EHLO", myHelo);
        this.writer.write(ehlo, buf);
        this.codecState = CodecState.EHLO_RESPONSE_EXPECTED;
        break;
      case HELO_READY:
        SMTPCommand helo = new SMTPCommand("HELO", myHelo);
        this.writer.write(helo, buf);
        this.codecState = CodecState.HELO_RESPONSE_EXPECTED;
        break;
    }

    if (buf.hasData()) {
      buf.flush(iosession.channel());
    }
    if (!buf.hasData()) {
      iosession.clearEvent(SelectionKey.OP_WRITE);
    }
  }
Ejemplo n.º 2
0
 public DefaultNHttpServerConnection createConnection(final IOSession iosession) {
   org.siddhiesb.transport.http.conn.SSLContextDetails customSSL = null;
   if (sslByIPMap != null) {
     customSSL = sslByIPMap.get(iosession.getLocalAddress());
   }
   if (customSSL == null) {
     customSSL = ssl;
   }
   IOSession customSession;
   if (customSSL != null) {
     customSession =
         new SSLIOSession(
             iosession, SSLMode.SERVER, customSSL.getContext(), customSSL.getHandler());
     iosession.setAttribute(SSLIOSession.SESSION_KEY, customSession);
   } else {
     customSession = iosession;
   }
   DefaultNHttpServerConnection conn =
       LoggingUtils.createServerConnection(customSession, requestFactory, allocator, params);
   int timeout = HttpConnectionParams.getSoTimeout(params);
   conn.setSocketTimeout(timeout);
   return conn;
 }