From 09b10cc80146c1ac2a0d5c53c6c8469b934189f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Mon, 25 Jun 2018 22:54:32 +0200 Subject: Throttle all commands sent to IRC servers fix #3354 --- src/irc/irc_client.hpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/irc/irc_client.hpp') diff --git a/src/irc/irc_client.hpp b/src/irc/irc_client.hpp index 70046be..ac5ccb0 100644 --- a/src/irc/irc_client.hpp +++ b/src/irc/irc_client.hpp @@ -16,8 +16,10 @@ #include #include #include +#include #include #include +#include class Bridge; @@ -84,8 +86,9 @@ public: * (actually, into our out_buf and signal the poller that we want to wach * for send events to be ready) */ - void send_message(IrcMessage&& message); + void send_message(IrcMessage message, bool throttle=true); void send_raw(const std::string& txt); + void actual_send(const IrcMessage& message); /** * Send the PONG irc command */ @@ -293,7 +296,7 @@ public: const std::vector& get_sorted_user_modes() const { return this->sorted_user_modes; } std::set get_chantypes() const { return this->chantypes; } - + void set_throttle_limit(std::size_t limit); /** * Store the history limit that the client asked when joining this room. */ @@ -330,6 +333,10 @@ private: * To communicate back with the bridge */ Bridge& bridge; + /** + * Where messaged are stored when they are throttled. + */ + std::deque message_queue{}; /** * The list of joined channels, indexed by name */ @@ -389,6 +396,7 @@ private: * the WebIRC protocole. */ Resolver dns_resolver; + TokensBucket tokens_bucket; }; -- cgit v1.2.3