From 26ffc8fe121e03e1b663aa0015a71b0fc914f95e Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Thu, 19 Jun 2014 22:21:49 +0200 Subject: Implement a way to add callbacks, waiting for an IRC event to return an iq --- src/irc/iid.cpp | 8 ++++++++ src/irc/iid.hpp | 2 +- src/irc/irc_client.cpp | 7 ++++++- 3 files changed, 15 insertions(+), 2 deletions(-) (limited to 'src/irc') diff --git a/src/irc/iid.cpp b/src/irc/iid.cpp index 4893e9e..0bb991f 100644 --- a/src/irc/iid.cpp +++ b/src/irc/iid.cpp @@ -20,6 +20,14 @@ Iid::Iid(const std::string& iid): this->set_server(iid); } +Iid::Iid(const Iid& other): + is_channel(other.is_channel), + is_user(other.is_user), + local(other.local), + server(other.server) +{ +} + Iid::Iid(): is_channel(false), is_user(false) diff --git a/src/irc/iid.hpp b/src/irc/iid.hpp index 2302a18..c547dea 100644 --- a/src/irc/iid.hpp +++ b/src/irc/iid.hpp @@ -43,6 +43,7 @@ class Iid { public: explicit Iid(const std::string& iid); + explicit Iid(const Iid&); explicit Iid(); void set_local(const std::string& loc); @@ -59,7 +60,6 @@ private: std::string local; std::string server; - Iid(const Iid&) = delete; Iid(Iid&&) = delete; Iid& operator=(const Iid&) = delete; Iid& operator=(Iid&&) = delete; diff --git a/src/irc/irc_client.cpp b/src/irc/irc_client.cpp index cc54971..d179aaa 100644 --- a/src/irc/irc_client.cpp +++ b/src/irc/irc_client.cpp @@ -136,8 +136,11 @@ void IrcClient::parse_in_buffer(const size_t) if (pos == std::string::npos) break ; IrcMessage message(this->in_buf.substr(0, pos)); - log_debug("IRC RECEIVING: " << message); this->in_buf = this->in_buf.substr(pos + 2, std::string::npos); + log_debug("IRC RECEIVING: " << message); + + // Call the standard callback (if any), associated with the command + // name that we just received. auto cb = irc_callbacks.find(message.command); if (cb != irc_callbacks.end()) { @@ -149,6 +152,8 @@ void IrcClient::parse_in_buffer(const size_t) } else log_info("No handler for command " << message.command); + // Try to find a waiting_iq, which response will be triggered by this IrcMessage + this->bridge->trigger_response_iq(this->hostname, message); } } -- cgit v1.2.3