X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/f4333737c7e347efe9258ccf85c1237e03be619c..1cd2b12bd4e4d86f6cd099240795f3ebeb3852b3:/projects/stargazer/plugins/other/smux/smux.cpp diff --git a/projects/stargazer/plugins/other/smux/smux.cpp b/projects/stargazer/plugins/other/smux/smux.cpp index f79085df..07f9d200 100644 --- a/projects/stargazer/plugins/other/smux/smux.cpp +++ b/projects/stargazer/plugins/other/smux/smux.cpp @@ -100,9 +100,6 @@ SMUX::SMUX() lastReconnectTry(0), reconnectTimeout(1), sock(-1), - addUserNotifier(*this), - delUserNotifier(*this), - addDelTariffNotifier(*this), logger(STG::PluginLogger::get("smux")) { smuxHandlers[SMUX_PDUs_PR_close] = &SMUX::CloseHandler; @@ -444,20 +441,27 @@ while (users->SearchNext(h, &u) == 0) users->CloseSearch(h); -users->AddNotifierUserAdd(&addUserNotifier); -users->AddNotifierUserDel(&delUserNotifier); - -tariffs->AddNotifierAdd(&addDelTariffNotifier); -tariffs->AddNotifierDel(&addDelTariffNotifier); +m_onAddUserConn = users->onAdd([this](auto user){ + SetNotifier(user); + UpdateTables(); +}); +m_onDelUserConn = users->onDel([this](auto user){ + UnsetNotifier(user); + UpdateTables(); +}); + +auto updateTables = [this](const STG::TariffData&){ UpdateTables(); }; +m_onAddTariffConn = tariffs->onAdd(updateTables); +m_onDelTariffConn = tariffs->onDel(updateTables); } void SMUX::ResetNotifiers() { -tariffs->DelNotifierDel(&addDelTariffNotifier); -tariffs->DelNotifierAdd(&addDelTariffNotifier); +m_onAddTariffConn.disconnect(); +m_onDelTariffConn.disconnect(); -users->DelNotifierUserDel(&delUserNotifier); -users->DelNotifierUserAdd(&addUserNotifier); +m_onAddUserConn.disconnect(); +m_onDelUserConn.disconnect(); auto it = notifiers.begin(); while (it != notifiers.end())