diff options
author | Remko Tronçon <git@el-tramo.be> | 2009-07-14 17:27:32 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2009-07-14 17:27:32 (GMT) |
commit | ee3a46975986865fe5064f9d87a27277fc6c235a (patch) | |
tree | 51bae2ed1669ca881f761ca7547fbaf22432ae12 /Swiften/Network/BoostConnection.h | |
parent | c34f50d3371f47c88d2ee927a5d59af8e135304c (diff) | |
download | swift-ee3a46975986865fe5064f9d87a27277fc6c235a.zip swift-ee3a46975986865fe5064f9d87a27277fc6c235a.tar.bz2 |
Consolidating IncomingConnection & Connection.
BoostConnections no longer have their own thread, but are managed from
a central Boost IO thread instead.
Diffstat (limited to 'Swiften/Network/BoostConnection.h')
-rw-r--r-- | Swiften/Network/BoostConnection.h | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/Swiften/Network/BoostConnection.h b/Swiften/Network/BoostConnection.h index f8fa514..85de926 100644 --- a/Swiften/Network/BoostConnection.h +++ b/Swiften/Network/BoostConnection.h @@ -1,5 +1,4 @@ -#ifndef SWIFTEN_BoostConnection_H -#define SWIFTEN_BoostConnection_H +#pragma once #include <boost/asio.hpp> @@ -15,29 +14,27 @@ namespace boost { namespace Swift { class BoostConnection : public Connection { public: - BoostConnection(const String& domain); + BoostConnection(boost::asio::io_service* ioService); ~BoostConnection(); - virtual void connect(); + virtual void listen(); + virtual void connect(const String& domain); virtual void disconnect(); virtual void write(const ByteArray& data); - private: - void doConnect(); - void doDisconnect(); + boost::asio::ip::tcp::socket& getSocket() { + return socket_; + } + private: void handleConnectFinished(const boost::system::error_code& error); void handleSocketRead(const boost::system::error_code& error, size_t bytesTransferred); + void handleDataWritten(const boost::system::error_code& error); void doRead(); - void doWrite(const ByteArray&); private: - boost::asio::io_service* ioService_; - boost::thread* thread_; - boost::asio::ip::tcp::socket* socket_; + boost::asio::ip::tcp::socket socket_; std::vector<char> readBuffer_; bool disconnecting_; }; } - -#endif |