summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2009-07-19 11:44:20 (GMT)
committerRemko Tronçon <git@el-tramo.be>2009-07-19 11:59:04 (GMT)
commit1de12ed346fc0018527afe082886129088e27a95 (patch)
tree16013a9294588f505a559a99fe27a603584f2ac2 /Swiften/Network
parent5d504472c63b7acaa7df99ff1097024cf463f1bd (diff)
downloadswift-contrib-1de12ed346fc0018527afe082886129088e27a95.zip
swift-contrib-1de12ed346fc0018527afe082886129088e27a95.tar.bz2
(Client)Session & Connection refactoring.
ClientSession no longer sets up a connection. Connection no longer resolves addresses.
Diffstat (limited to 'Swiften/Network')
-rw-r--r--Swiften/Network/BoostConnection.cpp14
-rw-r--r--Swiften/Network/BoostConnection.h1
-rw-r--r--Swiften/Network/Connection.h5
3 files changed, 3 insertions, 17 deletions
diff --git a/Swiften/Network/BoostConnection.cpp b/Swiften/Network/BoostConnection.cpp
index b064c7a..9f2a7da 100644
--- a/Swiften/Network/BoostConnection.cpp
+++ b/Swiften/Network/BoostConnection.cpp
@@ -48,16 +48,6 @@ void BoostConnection::listen() {
doRead();
}
-void BoostConnection::connect(const String& domain) {
- DomainNameResolver resolver;
- try {
- connect(resolver.resolve(domain.getUTF8String()));
- }
- catch (const DomainNameResolveException& e) {
- onDisconnected(DomainNameResolveError);
- }
-}
-
void BoostConnection::connect(const HostAddressPort& addressPort) {
boost::asio::ip::tcp::endpoint endpoint(
boost::asio::ip::address::from_string(addressPort.getAddress().toString()), addressPort.getPort());
@@ -78,11 +68,11 @@ void BoostConnection::write(const ByteArray& data) {
void BoostConnection::handleConnectFinished(const boost::system::error_code& error) {
if (!error) {
- MainEventLoop::postEvent(boost::bind(boost::ref(onConnected)), shared_from_this());
+ MainEventLoop::postEvent(boost::bind(boost::ref(onConnectFinished), false), shared_from_this());
doRead();
}
else if (error != boost::asio::error::operation_aborted) {
- MainEventLoop::postEvent(boost::bind(boost::ref(onDisconnected), ConnectionError), shared_from_this());
+ MainEventLoop::postEvent(boost::bind(boost::ref(onConnectFinished), true), shared_from_this());
}
}
diff --git a/Swiften/Network/BoostConnection.h b/Swiften/Network/BoostConnection.h
index 0ed6874..ae09fb8 100644
--- a/Swiften/Network/BoostConnection.h
+++ b/Swiften/Network/BoostConnection.h
@@ -20,7 +20,6 @@ namespace Swift {
~BoostConnection();
virtual void listen();
- virtual void connect(const String& domain);
virtual void connect(const HostAddressPort& address);
virtual void disconnect();
virtual void write(const ByteArray& data);
diff --git a/Swiften/Network/Connection.h b/Swiften/Network/Connection.h
index 25f9a16..a995774 100644
--- a/Swiften/Network/Connection.h
+++ b/Swiften/Network/Connection.h
@@ -11,8 +11,6 @@ namespace Swift {
class Connection {
public:
enum Error {
- DomainNameResolveError,
- ConnectionError,
ReadError,
WriteError
};
@@ -22,12 +20,11 @@ namespace Swift {
virtual void listen() = 0;
virtual void connect(const HostAddressPort& address) = 0;
- virtual void connect(const String& domain) = 0;
virtual void disconnect() = 0;
virtual void write(const ByteArray& data) = 0;
public:
- boost::signal<void ()> onConnected;
+ boost::signal<void (bool /* error */)> onConnectFinished;
boost::signal<void (const boost::optional<Error>&)> onDisconnected;
boost::signal<void (const ByteArray&)> onDataRead;
};