summaryrefslogtreecommitdiffstats
blob: 6d05eeed13907c78ed44decf9d4d9849c3715e68 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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