summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2011-11-12 16:56:21 (GMT)
committerKevin Smith <git@kismith.co.uk>2011-12-13 08:17:58 (GMT)
commit81c09a0f6a3e87b078340d7f35d0dea4c03f3a6d (patch)
tree4371c5808ee26b2b5ed79ace9ccb439ff2988945 /Swiften/Network/BOSHConnectionPool.h
parentfd17fe0d239f97cedebe4ceffa234155bd299b68 (diff)
downloadswift-contrib-81c09a0f6a3e87b078340d7f35d0dea4c03f3a6d.zip
swift-contrib-81c09a0f6a3e87b078340d7f35d0dea4c03f3a6d.tar.bz2
BOSH Support for Swiften
This adds support for BOSH to Swiften. It does not expose it to Swift. Release-Notes: Swiften now allows connects over BOSH, if used appropriately.
Diffstat (limited to 'Swiften/Network/BOSHConnectionPool.h')
-rw-r--r--Swiften/Network/BOSHConnectionPool.h64
1 files changed, 64 insertions, 0 deletions
diff --git a/Swiften/Network/BOSHConnectionPool.h b/Swiften/Network/BOSHConnectionPool.h
new file mode 100644
index 0000000..85e598d
--- /dev/null
+++ b/Swiften/Network/BOSHConnectionPool.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2011 Kevin Smith
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+
+#pragma once
+
+#include <vector>
+
+#include <Swiften/Base/SafeString.h>
+#include <Swiften/Network/BOSHConnectionFactory.h>
+#include <Swiften/Network/BOSHConnection.h>
+
+namespace Swift {
+ class HTTPConnectProxiedConnectionFactory;
+ class TLSConnectionFactory;
+ class BOSHConnectionPool : public boost::bsignals::trackable {
+ public:
+ BOSHConnectionPool(boost::shared_ptr<BOSHConnectionFactory> factory, const std::string& to, long initialRID, const URL& boshHTTPConnectProxyURL, const SafeString& boshHTTPConnectProxyAuthID, const SafeString& boshHTTPConnectProxyAuthPassword);
+ ~BOSHConnectionPool();
+ void write(const SafeByteArray& data);
+ void writeFooter();
+ void close();
+ void restartStream();
+
+ boost::signal<void (BOSHError::ref)> onSessionTerminated;
+ boost::signal<void ()> onSessionStarted;
+ boost::signal<void (const SafeByteArray&)> onXMPPDataRead;
+ boost::signal<void (const SafeByteArray&)> onBOSHDataRead;
+ boost::signal<void (const SafeByteArray&)> onBOSHDataWritten;
+
+ private:
+ void handleDataRead(const SafeByteArray& data);
+ void handleSessionStarted(const std::string& sid, size_t requests);
+ void handleBOSHDataRead(const SafeByteArray& data);
+ void handleBOSHDataWritten(const SafeByteArray& data);
+ void handleSessionTerminated(BOSHError::ref condition);
+ void handleConnectFinished(bool, BOSHConnection::ref connection);
+ void handleConnectionDisconnected(const boost::optional<Connection::Error>& error, BOSHConnection::ref connection);
+ void handleHTTPError(const std::string& errorCode);
+
+ private:
+ BOSHConnection::ref createConnection();
+ void destroyConnection(BOSHConnection::ref connection);
+ void tryToSendQueuedData();
+ BOSHConnection::ref getSuitableConnection();
+
+ private:
+ boost::shared_ptr<BOSHConnectionFactory> connectionFactory;
+ std::vector<BOSHConnection::ref> connections;
+ std::string sid;
+ unsigned long rid;
+ std::vector<SafeByteArray> dataQueue;
+ bool pendingTerminate;
+ std::string to;
+ size_t requestLimit;
+ int restartCount;
+ bool pendingRestart;
+ HTTPConnectProxiedConnectionFactory* connectProxyFactory;
+ TLSConnectionFactory* tlsConnectionFactory;
+ };
+}