summaryrefslogtreecommitdiff
path: root/src/irc
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2014-05-27 01:01:44 +0200
committerFlorent Le Coz <louiz@louiz.org>2014-05-27 01:01:44 +0200
commit5507adbe9473f4b41e52d16498f14850773e5e45 (patch)
tree34f2960edf6b73828537460cc50e6cdb9252a5e3 /src/irc
parent6b0ffb5fc2eca537e2cfaf24acb8a4d2ca9b99f1 (diff)
downloadbiboumi-5507adbe9473f4b41e52d16498f14850773e5e45.tar.gz
biboumi-5507adbe9473f4b41e52d16498f14850773e5e45.tar.bz2
biboumi-5507adbe9473f4b41e52d16498f14850773e5e45.tar.xz
biboumi-5507adbe9473f4b41e52d16498f14850773e5e45.zip
SocketHandlers own the poller and add themself into it only when the socket is created
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.
Diffstat (limited to 'src/irc')
-rw-r--r--src/irc/irc_client.cpp3
-rw-r--r--src/irc/irc_client.hpp3
2 files changed, 4 insertions, 2 deletions
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 <string>
using namespace std::string_literals;
-IrcClient::IrcClient(const std::string& hostname, const std::string& username, Bridge* bridge):
+IrcClient::IrcClient(std::shared_ptr<Poller> 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 <network/socket_handler.hpp>
#include <unordered_map>
+#include <memory>
#include <vector>
#include <string>
#include <map>
@@ -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> poller, const std::string& hostname, const std::string& username, Bridge* bridge);
~IrcClient();
/**
* Connect to the IRC server