IoFuture<? extends StreamConnection> result;
if (ssl != null) {
result = HttpUpgrade.performUpgrade(worker, ssl, null, newUri, headers, new ChannelListener<StreamConnection>() {
@Override
public void handleEvent(StreamConnection channel) {
WebSocketChannel result = handshake.createChannel(channel, newUri.toString(), bufferPool);
ioFuture.setResult(result);
}
}, null, optionMap, handshake.handshakeChecker(newUri, headers));
} else {
result = HttpUpgrade.performUpgrade(worker, null, newUri, headers, new ChannelListener<StreamConnection>() {
@Override
public void handleEvent(StreamConnection channel) {
WebSocketChannel result = handshake.createChannel(channel, newUri.toString(), bufferPool);
ioFuture.setResult(result);
}
}, null, optionMap, handshake.handshakeChecker(newUri, headers));
}
result.addNotifier(new IoFuture.Notifier<StreamConnection, Object>() {
@Override
public void notify(IoFuture<? extends StreamConnection> res, Object attachment) {
if (res.getStatus() == IoFuture.Status.FAILED) {
ioFuture.setException(res.getException());
}