From 5507adbe9473f4b41e52d16498f14850773e5e45 Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Tue, 27 May 2014 01:01:44 +0200 Subject: SocketHandlers own the poller and add themself into it only when the socket is created MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We want to call socket() with the parameters provided by getaddrinfo, so we can’t addd the fd into the poller immediately. We need to wait the connection attempt, and then the SocketHandler can call add_socket_handler itself, if the connection succeeds, or is in progress. --- src/irc/irc_client.cpp | 3 ++- src/irc/irc_client.hpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'src/irc') diff --git a/src/irc/irc_client.cpp b/src/irc/irc_client.cpp index c149311..cea08f2 100644 --- a/src/irc/irc_client.cpp +++ b/src/irc/irc_client.cpp @@ -13,7 +13,8 @@ #include using namespace std::string_literals; -IrcClient::IrcClient(const std::string& hostname, const std::string& username, Bridge* bridge): +IrcClient::IrcClient(std::shared_ptr poller, const std::string& hostname, const std::string& username, Bridge* bridge): + SocketHandler(poller), hostname(hostname), username(username), current_nick(username), diff --git a/src/irc/irc_client.hpp b/src/irc/irc_client.hpp index a2e2afe..e70ee33 100644 --- a/src/irc/irc_client.hpp +++ b/src/irc/irc_client.hpp @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -23,7 +24,7 @@ class Bridge; class IrcClient: public SocketHandler { public: - explicit IrcClient(const std::string& hostname, const std::string& username, Bridge* bridge); + explicit IrcClient(std::shared_ptr poller, const std::string& hostname, const std::string& username, Bridge* bridge); ~IrcClient(); /** * Connect to the IRC server -- cgit v1.2.3