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.
This commit is contained in:
1 parent
6b0ffb5fc2
commit
5507adbe94
11 files changed
+29
-39
No files matched your search
@@ -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),
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user