diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/bridge/bridge.cpp | 5 | ||||
-rw-r--r-- | src/bridge/bridge.hpp | 4 | ||||
-rw-r--r-- | src/xmpp/xmpp_component.cpp | 7 |
3 files changed, 15 insertions, 1 deletions
diff --git a/src/bridge/bridge.cpp b/src/bridge/bridge.cpp index 5122a69..bb3bfb0 100644 --- a/src/bridge/bridge.cpp +++ b/src/bridge/bridge.cpp @@ -249,6 +249,11 @@ std::string Bridge::get_own_nick(const Iid& iid) return ""; } +size_t Bridge::connected_clients() const +{ + return this->irc_clients.size(); +} + void Bridge::kick_muc_user(Iid&& iid, const std::string& target, const std::string& reason, const std::string& author) { this->xmpp->kick_user(iid.chan + "%" + iid.server, target, reason, author, this->user_jid); diff --git a/src/bridge/bridge.hpp b/src/bridge/bridge.hpp index b3a5d02..58ca24c 100644 --- a/src/bridge/bridge.hpp +++ b/src/bridge/bridge.hpp @@ -104,6 +104,10 @@ public: * Misc */ std::string get_own_nick(const Iid& iid); + /** + * Get the number of server to which this bridge is connected. + */ + size_t connected_clients() const; private: /** diff --git a/src/xmpp/xmpp_component.cpp b/src/xmpp/xmpp_component.cpp index 2fb8a23..e059764 100644 --- a/src/xmpp/xmpp_component.cpp +++ b/src/xmpp/xmpp_component.cpp @@ -99,9 +99,14 @@ void XmppComponent::shutdown() void XmppComponent::clean() { - for (auto it = this->bridges.begin(); it != this->bridges.end(); ++it) + auto it = this->bridges.begin(); + while (it != this->bridges.end()) { it->second->clean(); + if (it->second->connected_clients() == 0) + it = this->bridges.erase(it); + else + ++it; } } |