void HTTPRequest::handleConnectFinished(Swift::Connection::ref connection) { cancelConnector(); connection_ = connection; if (connection) { connection_->onDataRead.connect(boost::bind(&HTTPRequest::handleDataRead, shared_from_this(), _1)); connection_->onDisconnected.connect(boost::bind(&HTTPRequest::handleDisconnected, shared_from_this(), _1)); } else { cancelConnector(); onError(); } writeData(); }
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_); } }
BOSHConnection::~BOSHConnection() { cancelConnector(); if (connection_) { connection_->onDataRead.disconnect(boost::bind(&BOSHConnection::handleDataRead, shared_from_this(), _1)); connection_->onDisconnected.disconnect(boost::bind(&BOSHConnection::handleDisconnected, shared_from_this(), _1)); } BOSHConnection::disconnect(); }
void HTTPRequest::handleDisconnected(const boost::optional<Swift::Connection::Error>& error) { //std::cerr << "HTTP Disconnected" << std::endl; cancelConnector(); if (receivedHeaders_) { onComplete(Swift::createByteArray(safeByteArrayToString(buffer_))); // Yes, this is getting a little silly with the conversions. } else { onError(); } connection_.reset(); // Delete the connection, the signals that keep the HTTPRequest alive get cleared, this gets cleaned up. }
HTTPRequest::~HTTPRequest() { cancelConnector(); }
void BOSHConnection::handleDisconnected(const boost::optional<Connection::Error>& error) { cancelConnector(); onDisconnected(error ? true : false); sid_ = ""; connectionReady_ = false; }