Example usage for org.apache.http.nio.reactor IOSession setEventMask

List of usage examples for org.apache.http.nio.reactor IOSession setEventMask

Introduction

In this page you can find the example usage for org.apache.http.nio.reactor IOSession setEventMask.

Prototype

void setEventMask(int ops);

Source Link

Document

Declares interest in I/O event notifications by setting the event mask associated with the session

Usage

From source file:com.ok2c.lightmtp.impl.protocol.ExtendedSendHeloCodec.java

@Override
public void reset(final IOSession iosession, final ClientState sessionState)
        throws IOException, SMTPProtocolException {
    this.parser.reset();
    this.writer.reset();
    this.codecState = CodecState.SERVICE_READY_EXPECTED;

    iosession.setEventMask(SelectionKey.OP_READ);
}

From source file:com.ok2c.lightmtp.impl.protocol.ServiceShutdownCodec.java

@Override
public void reset(final IOSession iosession, final ServerState sessionState)
        throws IOException, SMTPProtocolException {
    this.writer.reset();
    this.pendingReply = new SMTPReply(SMTPCodes.ERR_TRANS_SERVICE_NOT_AVAILABLE, new SMTPCode(4, 3, 0),
            sessionState.getServerId() + " service shutting down " + "and closing transmission channel");
    this.completed = false;

    iosession.setEventMask(SelectionKey.OP_WRITE);
}

From source file:com.ok2c.lightmtp.impl.protocol.ServiceReadyCodec.java

@Override
public void produceData(final IOSession iosession, final ServerState sessionState)
        throws IOException, SMTPProtocolException {
    Args.notNull(iosession, "IO session");
    Args.notNull(sessionState, "Session state");

    SessionOutputBuffer buf = this.iobuffers.getOutbuf();

    if (this.pendingReply != null) {
        this.writer.write(this.pendingReply, buf);
        this.pendingReply = null;
    }/*  w  w w  .j  a va 2 s  .com*/

    if (buf.hasData()) {
        buf.flush(iosession.channel());
    }
    if (!buf.hasData()) {
        this.completed = true;
        iosession.setEventMask(SelectionKey.OP_READ);
    }
}

From source file:com.ok2c.lightmtp.impl.protocol.ServiceReadyCodec.java

@Override
public void reset(final IOSession iosession, final ServerState sessionState)
        throws IOException, SMTPProtocolException {
    this.writer.reset();

    InetSocketAddress socketAddress = (InetSocketAddress) iosession.getRemoteAddress();
    InetAddress clientAddress = socketAddress.getAddress();

    if (this.addressValidator != null) {
        if (!this.addressValidator.validateAddress(clientAddress)) {
            sessionState.terminated();/*from   w  w  w.  j  a  va 2  s  .  com*/
            iosession.close();
            return;
        }
    }

    sessionState.setClientAddress(clientAddress);

    this.pendingReply = new SMTPReply(SMTPCodes.SERVICE_READY, null,
            sessionState.getServerId() + " service ready");
    this.completed = false;

    iosession.setEventMask(SelectionKey.OP_WRITE);
}