...
This commit is contained in:
parent
3e8a113c3a
commit
143f54b989
@ -7,6 +7,7 @@ ABSTRACT DEVICE COMPONENTS LIBRARY
|
||||
*/
|
||||
|
||||
#include <filesystem>
|
||||
#include <functional>
|
||||
#include <set>
|
||||
#include <unordered_map>
|
||||
|
||||
@ -262,12 +263,30 @@ protected:
|
||||
// started sessions waek pointers
|
||||
template <traits::adc_netserver_session_c SessionT>
|
||||
static std::unordered_map<const AdcNetServer*, std::set<typename SessionT::weak_ptr_t>> _serverSessions;
|
||||
std::vector<std::function<void()>> _stopSessionFunc;
|
||||
|
||||
template <traits::adc_netserver_session_c SessionT>
|
||||
void startAsyncSession(const typename SessionT::shared_ptr_t& sess_ptr)
|
||||
void startSession(const typename SessionT::shared_ptr_t& sess_ptr)
|
||||
{
|
||||
_serverSessions<SessionT>[this].insert(sess_ptr);
|
||||
sess_ptr.start();
|
||||
auto res = _serverSessions<SessionT>[this].emplace(sess_ptr);
|
||||
if (res.second) {
|
||||
sess_ptr.start();
|
||||
|
||||
_stopSessionFunc.emplace_back([res]() {
|
||||
if (!res.first.expired()) { // session is still existing
|
||||
auto sess = res.first.lock();
|
||||
sess->stop();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void stopAllSessions()
|
||||
{
|
||||
for (auto& func : _stopSessionFunc) {
|
||||
func();
|
||||
}
|
||||
}
|
||||
|
||||
virtual void daemonizePrepare()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user