diff options
author | Remko Tronçon <git@el-tramo.be> | 2010-06-18 21:17:26 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2010-06-18 21:27:59 (GMT) |
commit | 154bf14ac15fc7bff918c20814b29b5cc3bc5ba4 (patch) | |
tree | 28f18493bb6bc1cbf85b90f391daa6c4e1ecb3aa /Swiften/Network/BoostConnectionServer.h | |
parent | b763087e13f25e08aa51a6568b03727f136de34e (diff) | |
download | swift-contrib-154bf14ac15fc7bff918c20814b29b5cc3bc5ba4.zip swift-contrib-154bf14ac15fc7bff918c20814b29b5cc3bc5ba4.tar.bz2 |
Fix crash on reconnect.
BoostTimer isn't supposed to be constructed as a non-shared-ptr. Making
constructor private to avoid this error in the future.
Diffstat (limited to 'Swiften/Network/BoostConnectionServer.h')
-rw-r--r-- | Swiften/Network/BoostConnectionServer.h | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/Swiften/Network/BoostConnectionServer.h b/Swiften/Network/BoostConnectionServer.h index 311be4b..3a3c096 100644 --- a/Swiften/Network/BoostConnectionServer.h +++ b/Swiften/Network/BoostConnectionServer.h @@ -18,18 +18,25 @@ namespace Swift { class BoostConnectionServer : public ConnectionServer, public EventOwner, public boost::enable_shared_from_this<BoostConnectionServer> { public: + typedef boost::shared_ptr<BoostConnectionServer> ref; + enum Error { Conflict, UnknownError }; - BoostConnectionServer(int port, boost::asio::io_service* ioService); + static ref create(int port, boost::asio::io_service* ioService) { + return ref(new BoostConnectionServer(port, ioService)); + } + void start(); void stop(); boost::signal<void (boost::optional<Error>)> onStopped; private: + BoostConnectionServer(int port, boost::asio::io_service* ioService); + void stop(boost::optional<Error> e); void acceptNextConnection(); void handleAccept(boost::shared_ptr<BoostConnection> newConnection, const boost::system::error_code& error); |