/* * Copyright (c) 2010-2011 Thilo Cestonaro * Licensed under the simplified BSD license. * See Documentation/Licenses/BSD-simplified.txt for more information. */ /* * Copyright (c) 2011 Kevin Smith * Licensed under the GNU General Public License v3. * See Documentation/Licenses/GPLv3.txt for more information. */ #pragma once #include #include #include #include namespace boost { class thread; namespace system { class error_code; } } namespace Swift { class ConnectionFactory; class HTTPConnectProxiedConnection : public Connection, public boost::enable_shared_from_this { public: typedef boost::shared_ptr ref; ~HTTPConnectProxiedConnection(); static ref create(ConnectionFactory* connectionFactory, HostAddressPort proxy, const SafeString& authID, const SafeString& authPassword) { return ref(new HTTPConnectProxiedConnection(connectionFactory, proxy, authID, authPassword)); } virtual void listen(); virtual void connect(const HostAddressPort& address); virtual void disconnect(); virtual void write(const SafeByteArray& data); virtual HostAddressPort getLocalAddress() const; private: HTTPConnectProxiedConnection(ConnectionFactory* connectionFactory, HostAddressPort proxy, const SafeString& authID, const SafeString& authPassword); void handleConnectionConnectFinished(bool error); void handleDataRead(boost::shared_ptr data); void handleDisconnected(const boost::optional& error); private: bool connected_; ConnectionFactory* connectionFactory_; HostAddressPort proxy_; HostAddressPort server_; SafeByteArray authID_; SafeByteArray authPassword_; boost::shared_ptr connection_; }; }