summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Network/Connection.h')
-rw-r--r--Swiften/Network/Connection.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/Swiften/Network/Connection.h b/Swiften/Network/Connection.h
new file mode 100644
index 0000000..6d05eee
--- /dev/null
+++ b/Swiften/Network/Connection.h
@@ -0,0 +1,40 @@
+#ifndef SWIFTEN_CONNECTION_H
+#define SWIFTEN_CONNECTION_H
+
+#include <boost/signals.hpp>
+
+#include "Swiften/Base/ByteArray.h"
+#include "Swiften/Base/String.h"
+
+namespace Swift {
+ class Connection {
+ public:
+ enum Error {
+ DomainNameResolveError,
+ ConnectionError,
+ ReadError
+ };
+
+ Connection(const String& domain) : domain_(domain) {}
+ virtual ~Connection() {}
+
+ virtual void connect() = 0;
+ virtual void disconnect() = 0;
+ virtual void write(const ByteArray& data) = 0;
+
+ public:
+ boost::signal<void ()> onConnected;
+ boost::signal<void (Error)> onError;
+ boost::signal<void (const ByteArray&)> onDataRead;
+
+ protected:
+ const String& getDomain() const {
+ return domain_;
+ }
+
+ private:
+ String domain_;
+ };
+}
+
+#endif