use of io.github.tesla.gateway.netty.transmit.ConnectionState in project tesla by linking12.
the class ProxyConnection method readHTTP.
@SuppressWarnings("unchecked")
private void readHTTP(HttpObject httpObject) {
ConnectionState nextState = getCurrentState();
switch(getCurrentState()) {
case AWAITING_INITIAL:
if (httpObject instanceof HttpMessage) {
nextState = readHTTPInitial((I) httpObject);
} else {
LOG.debug("Dropping message because HTTP object was not an HttpMessage. HTTP object may be orphaned content from a short-circuited response. Message: {}", httpObject);
}
break;
case AWAITING_CHUNK:
HttpContent chunk = (HttpContent) httpObject;
readHTTPChunk(chunk);
nextState = ProxyUtils.isLastChunk(chunk) ? AWAITING_INITIAL : AWAITING_CHUNK;
break;
case AWAITING_PROXY_AUTHENTICATION:
if (httpObject instanceof HttpRequest) {
nextState = readHTTPInitial((I) httpObject);
} else {
}
break;
case CONNECTING:
LOG.warn("Attempted to read from connection that's in the process of connecting. This shouldn't happen.");
break;
case NEGOTIATING_CONNECT:
LOG.debug("Attempted to read from connection that's in the process of negotiating an HTTP CONNECT. This is probably the LastHttpContent of a chunked CONNECT.");
break;
case AWAITING_CONNECT_OK:
LOG.warn("AWAITING_CONNECT_OK should have been handled by ProxyToServerConnection.read()");
break;
case HANDSHAKING:
LOG.warn("Attempted to read from connection that's in the process of handshaking. This shouldn't happen.", channel);
break;
case DISCONNECT_REQUESTED:
case DISCONNECTED:
LOG.info("Ignoring message since the connection is closed or about to close");
break;
}
become(nextState);
}
use of io.github.tesla.gateway.netty.transmit.ConnectionState in project tesla by linking12.
the class ConnectionFlow method fail.
@SuppressWarnings({ "unchecked", "rawtypes" })
public void fail(final Throwable cause) {
final ConnectionState lastStateBeforeFailure = serverConnection.getCurrentState();
serverConnection.disconnect().addListener(new GenericFutureListener() {
@Override
public void operationComplete(Future future) throws Exception {
synchronized (connectLock) {
if (!clientConnection.serverConnectionFailed(serverConnection, lastStateBeforeFailure, cause)) {
serverConnection.become(ConnectionState.DISCONNECTED);
notifyThreadsWaitingForConnection();
}
}
}
});
}
Aggregations