use of org.apache.hc.core5.reactor.IOEventHandler in project httpcomponents-core by apache.
the class LoggingIOSession method upgrade.
@Override
public void upgrade(final IOEventHandler handler) {
Args.notNull(handler, "Protocol handler");
if (this.log.isDebugEnabled()) {
this.log.debug("{} protocol upgrade: {}", this.session, handler.getClass());
}
this.session.upgrade(new IOEventHandler() {
@Override
public void connected(final IOSession protocolSession) throws IOException {
handler.connected(protocolSession);
}
@Override
public void inputReady(final IOSession protocolSession, final ByteBuffer src) throws IOException {
if (src != null && wireLog.isDebugEnabled()) {
final ByteBuffer b = src.duplicate();
logData(b, "<< ");
}
handler.inputReady(protocolSession, src);
}
@Override
public void outputReady(final IOSession protocolSession) throws IOException {
handler.outputReady(protocolSession);
}
@Override
public void timeout(final IOSession protocolSession, final Timeout timeout) throws IOException {
handler.timeout(protocolSession, timeout);
}
@Override
public void exception(final IOSession protocolSession, final Exception cause) {
handler.exception(protocolSession, cause);
}
@Override
public void disconnected(final IOSession protocolSession) {
handler.disconnected(protocolSession);
}
});
}
use of org.apache.hc.core5.reactor.IOEventHandler in project httpcomponents-core by apache.
the class InternalDataChannel method onIOEvent.
@Override
void onIOEvent(final int readyOps) throws IOException {
if ((readyOps & SelectionKey.OP_CONNECT) != 0) {
final IOSession currentSession = currentSessionRef.get();
currentSession.clearEvent(SelectionKey.OP_CONNECT);
if (tlsSessionRef.get() == null) {
if (sessionListener != null) {
sessionListener.connected(currentSession);
}
final IOEventHandler handler = ensureHandler(currentSession);
handler.connected(currentSession);
}
}
if ((readyOps & SelectionKey.OP_READ) != 0) {
final IOSession currentSession = currentSessionRef.get();
currentSession.updateReadTime();
if (sessionListener != null) {
sessionListener.inputReady(currentSession);
}
final IOEventHandler handler = ensureHandler(currentSession);
handler.inputReady(currentSession, null);
}
if ((readyOps & SelectionKey.OP_WRITE) != 0 || (ioSession.getEventMask() & SelectionKey.OP_WRITE) != 0) {
final IOSession currentSession = currentSessionRef.get();
currentSession.updateWriteTime();
if (sessionListener != null) {
sessionListener.outputReady(currentSession);
}
final IOEventHandler handler = ensureHandler(currentSession);
handler.outputReady(currentSession);
}
}
use of org.apache.hc.core5.reactor.IOEventHandler in project httpcomponents-core by apache.
the class InternalDataChannel method upgrade.
@Override
public void upgrade(final IOEventHandler handler) {
final IOSession currentSession = currentSessionRef.get();
currentSession.upgrade(handler);
eventHandlerRef.set(handler);
}
use of org.apache.hc.core5.reactor.IOEventHandler in project httpcomponents-core by apache.
the class InternalDataChannel method disconnected.
void disconnected() {
final IOSession currentSession = currentSessionRef.get();
if (sessionListener != null) {
sessionListener.disconnected(currentSession);
}
final IOEventHandler handler = currentSession.getHandler();
if (handler != null) {
handler.disconnected(currentSession);
}
}
use of org.apache.hc.core5.reactor.IOEventHandler in project httpcomponents-core by apache.
the class InternalDataChannel method onTimeout.
@Override
void onTimeout(final Timeout timeout) throws IOException {
final IOSession currentSession = currentSessionRef.get();
if (sessionListener != null) {
sessionListener.timeout(currentSession);
}
final IOEventHandler handler = ensureHandler(currentSession);
handler.timeout(currentSession, timeout);
}
Aggregations