void BOSHConnection::handleConnectFinished(Connection::ref connection) { cancelConnector(); connectionReady_ = !!connection; if (connectionReady_) { connection_ = connection; if (tlsLayer_) { connection_->onDataRead.connect(boost::bind(&BOSHConnection::handleRawDataRead, shared_from_this(), _1)); connection_->onDisconnected.connect(boost::bind(&BOSHConnection::handleDisconnected, shared_from_this(), _1)); tlsLayer_->getContext()->onDataForNetwork.connect(boost::bind(&BOSHConnection::handleTLSNetowrkDataWriteRequest, shared_from_this(), _1)); tlsLayer_->getContext()->onDataForApplication.connect(boost::bind(&BOSHConnection::handleTLSApplicationDataRead, shared_from_this(), _1)); tlsLayer_->onConnected.connect(boost::bind(&BOSHConnection::handleTLSConnected, shared_from_this())); tlsLayer_->onError.connect(boost::bind(&BOSHConnection::handleTLSError, shared_from_this(), _1)); tlsLayer_->connect(); } else { connection_->onDataRead.connect(boost::bind(&BOSHConnection::handleDataRead, shared_from_this(), _1)); connection_->onDisconnected.connect(boost::bind(&BOSHConnection::handleDisconnected, shared_from_this(), _1)); } } if (!connectionReady_ || !tlsLayer_) { onConnectFinished(!connectionReady_); } }
void TLSConnection::handleRawConnectFinished(bool error) { connection->onConnectFinished.disconnect(boost::bind(&TLSConnection::handleRawConnectFinished, this, _1)); if (error) { onConnectFinished(true); } else { context->connect(); } }
void LinkLocalConnector::handleHostnameResolved(const boost::optional<HostAddress>& address) { resolveQuery->finish(); resolveQueryHostNameResolvedConnection.disconnect(); resolveQuery.reset(); if (address) { connectionConnectFinishedConnection = connection->onConnectFinished.connect( boost::bind(&LinkLocalConnector::handleConnected, shared_from_this(), _1)); connection->connect(HostAddressPort(*address, service.getPort())); } else { onConnectFinished(true); } }
void Connector::finish(boost::shared_ptr<Connection> connection) { if (timer) { timer->stop(); timer->onTick.disconnect(boost::bind(&Connector::handleTimeout, shared_from_this())); timer.reset(); } if (serviceQuery) { serviceQuery->onResult.disconnect(boost::bind(&Connector::handleServiceQueryResult, shared_from_this(), _1)); serviceQuery.reset(); } if (addressQuery) { addressQuery->onResult.disconnect(boost::bind(&Connector::handleAddressQueryResult, shared_from_this(), _1, _2)); addressQuery.reset(); } if (currentConnection) { currentConnection->onConnectFinished.disconnect(boost::bind(&Connector::handleConnectionConnectFinished, shared_from_this(), _1)); currentConnection.reset(); } onConnectFinished(connection, (connection || foundSomeDNS) ? boost::shared_ptr<Error>() : boost::make_shared<DomainNameResolveError>()); }
void BOSHConnection::handleTLSConnected() { SWIFT_LOG(debug) << std::endl; onConnectFinished(false); }
void LinkLocalConnector::handleConnected(bool error) { onConnectFinished(error); assert(connectionConnectFinishedConnection.connected()); connectionConnectFinishedConnection.disconnect(); }
void TLSConnection::handleTLSConnectFinished(bool error) { onConnectFinished(error); if (error) { disconnect(); } }