]> git.stg.codes - stg.git/blobdiff - projects/stargazer/plugins/other/ping/ping.cpp
More subscriptions, less notifiers.
[stg.git] / projects / stargazer / plugins / other / ping / ping.cpp
index 260f4aefbc77c22efa303c41fb67630da6210883..71752de60719ef461981f9f060dc2d85ebc29a8f 100644 (file)
@@ -63,8 +63,6 @@ return 0;
 PING::PING()
     : users(nullptr),
       isRunning(false),
-      onAddUserNotifier(*this),
-      onDelUserNotifier(*this),
       logger(STG::PluginLogger::get("ping"))
 {
 }
@@ -81,8 +79,8 @@ int PING::Start()
 {
 GetUsers();
 
-users->AddNotifierUserAdd(&onAddUserNotifier);
-users->AddNotifierUserDel(&onDelUserNotifier);
+m_onAddUserConn = users->onAdd([this](auto user){ AddUser(user); });
+m_onDelUserConn = users->onDel([this](auto user){ DelUser(user); });
 
 pinger.SetDelayTime(pingSettings.GetPingDelay());
 pinger.Start();
@@ -111,8 +109,8 @@ for (int i = 0; i < 25; i++)
     nanosleep(&ts, nullptr);
     }
 
-users->DelNotifierUserAdd(&onAddUserNotifier);
-users->DelNotifierUserDel(&onDelUserNotifier);
+m_onAddUserConn.disconnect();
+m_onDelUserConn.disconnect();
 
 std::list<UserPtr>::iterator users_iter;
 users_iter = usersList.begin();
@@ -291,14 +289,14 @@ while (users_iter != usersList.end())
     }
 }
 //-----------------------------------------------------------------------------
-void CHG_CURRIP_NOTIFIER_PING::Notify(const uint32_t & oldIP, const uint32_t & newIP)
+void CHG_CURRIP_NOTIFIER_PING::notify(const uint32_t & oldIP, const uint32_t & newIP)
 {
 ping.pinger.DelIP(oldIP);
 if (newIP != 0)
     ping.pinger.AddIP(newIP);
 }
 //-----------------------------------------------------------------------------
-void CHG_IPS_NOTIFIER_PING::Notify(const STG::UserIPs & oldIPS, const STG::UserIPs & newIPS)
+void CHG_IPS_NOTIFIER_PING::notify(const STG::UserIPs & oldIPS, const STG::UserIPs & newIPS)
 {
 if (oldIPS.onlyOneIP())
     ping.pinger.DelIP(oldIPS[0].ip);
@@ -306,14 +304,3 @@ if (oldIPS.onlyOneIP())
 if (newIPS.onlyOneIP())
     ping.pinger.AddIP(newIPS[0].ip);
 }
-//-----------------------------------------------------------------------------
-void ADD_USER_NONIFIER_PING::Notify(const UserPtr & user)
-{
-ping.AddUser(user);
-}
-//-----------------------------------------------------------------------------
-void DEL_USER_NONIFIER_PING::Notify(const UserPtr & user)
-{
-ping.DelUser(user);
-}
-//-----------------------------------------------------------------------------