diff options
author | Thilo Cestonaro <thilo@cestona.ro> | 2011-09-28 22:03:14 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2011-12-13 08:17:58 (GMT) |
commit | fd17fe0d239f97cedebe4ceffa234155bd299b68 (patch) | |
tree | 010ae5155e6e807b548861304657a25699487e1f /Swiften/Network/BOSHConnection.h | |
parent | 7d19f0d81371d86d530d0e7083a04db914ce6745 (diff) | |
download | swift-contrib-fd17fe0d239f97cedebe4ceffa234155bd299b68.zip swift-contrib-fd17fe0d239f97cedebe4ceffa234155bd299b68.tar.bz2 |
BOSH implementation started
License: This patch is BSD-licensed, see http://www.opensource.org/licenses/bsd-license.php
Diffstat (limited to 'Swiften/Network/BOSHConnection.h')
-rw-r--r-- | Swiften/Network/BOSHConnection.h | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/Swiften/Network/BOSHConnection.h b/Swiften/Network/BOSHConnection.h new file mode 100644 index 0000000..0da92ba --- /dev/null +++ b/Swiften/Network/BOSHConnection.h @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2011 Thilo Cestonaro + * Licensed under the simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +#pragma once + +#include <boost/enable_shared_from_this.hpp> + +#include <Swiften/Network/Connection.h> +#include <Swiften/Network/HostAddressPort.h> +#include <Swiften/Base/String.h> + +namespace boost { + class thread; + namespace system { + class error_code; + } +} + +namespace Swift { + class ConnectionFactory; + + class BOSHConnection : public Connection, public boost::enable_shared_from_this<BOSHConnection> { + public: + typedef boost::shared_ptr<BOSHConnection> ref; + static ref create(ConnectionFactory* connectionFactory) { + return ref(new BOSHConnection(connectionFactory)); + } + virtual ~BOSHConnection(); + virtual void listen(); + virtual void connect(const HostAddressPort& address); + virtual void disconnect(); + virtual void write(const SafeByteArray& data); + virtual HostAddressPort getLocalAddress() const; + + private: + BOSHConnection(ConnectionFactory* connectionFactory); + + void handleConnectionConnectFinished(bool error); + void handleDataRead(const SafeByteArray& data); + void handleDisconnected(const boost::optional<Error>& error); + + bool reopenAfterAction; + ConnectionFactory* connectionFactory_; + HostAddressPort server_; + boost::shared_ptr<Connection> newConnection_; + boost::shared_ptr<Connection> currentConnection_; + std::string sid_; + }; +} |