WebFramework v3.0.12
Web framework for C++.
Loading...
Searching...
No Matches
SessionsManager.h
1#pragma once
2
3#include "Import/WebFrameworkCore.h"
4
5namespace framework
6{
8 {
9 private:
10 class SessionTime
11 {
12 public:
13 using SessionTimePoint = std::chrono::high_resolution_clock::time_point;
14
15 private:
16 std::multimap<SessionTimePoint, std::string, std::greater<SessionTimePoint>> timeIp;
17 std::unordered_map<std::string, SessionTimePoint> ipTime;
18 std::mutex checkLock;
19 SessionsManager* userSessionSynchronization;
20
21 private:
22 void asyncCheck();
23
24 void runAsyncCheck();
25
26 void nextPeriod();
27
28 public:
29 SessionTime(SessionsManager* userSession);
30
31 void updateSessionTime(const std::string& ip);
32
33 ~SessionTime() = default;
34 };
35
36 private:
37 SessionTime time;
38 std::unordered_map<std::string, std::unordered_map<std::string, std::string>> userSession; // ip - (key - value)
39 std::mutex lock;
40
41 public:
43
44 void setAttribute(const std::string& ip, const std::string& name, const std::string& value);
45
46 std::string getAttribute(const std::string& ip, const std::string& name);
47
48 void deleteSession(const std::string& ip);
49
50 void deleteAttribute(const std::string& ip, const std::string& name);
51
52 ~SessionsManager() = default;
53 };
54}