Commit 61ca40fa authored by louiz’'s avatar louiz’

Delete empty bridges objects

parent 190c4ff1
...@@ -249,6 +249,11 @@ std::string Bridge::get_own_nick(const Iid& iid) ...@@ -249,6 +249,11 @@ std::string Bridge::get_own_nick(const Iid& iid)
return ""; 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) 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); this->xmpp->kick_user(iid.chan + "%" + iid.server, target, reason, author, this->user_jid);
......
...@@ -104,6 +104,10 @@ public: ...@@ -104,6 +104,10 @@ public:
* Misc * Misc
*/ */
std::string get_own_nick(const Iid& iid); 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: private:
/** /**
......
...@@ -99,9 +99,14 @@ void XmppComponent::shutdown() ...@@ -99,9 +99,14 @@ void XmppComponent::shutdown()
void XmppComponent::clean() 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(); it->second->clean();
if (it->second->connected_clients() == 0)
it = this->bridges.erase(it);
else
++it;
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment