rcpp_framework/core/http/session_manager.h

41 lines
871 B
C
Raw Normal View History

2021-08-04 21:10:43 +02:00
#ifndef SESSION_MANAGER_H
#define SESSION_MANAGER_H
2021-08-04 21:02:34 +02:00
#include "core/object.h"
#include <map>
#include <mutex>
#include <string>
#include <vector>
class HTTPSession;
class Request;
2021-08-04 21:02:34 +02:00
class SessionManager : public Object {
public:
void add_session(HTTPSession *session);
void remove_session(HTTPSession *session);
void delete_session(const std::string &session_id);
HTTPSession *get_session(const std::string &session_id);
HTTPSession *create_session();
void clear();
virtual std::string generate_session_id(const std::string &base = "");
static void session_setup_middleware(Object *instance, Request *request);
2021-08-04 21:02:34 +02:00
static SessionManager *get_singleton();
SessionManager();
~SessionManager();
std::map<std::string, HTTPSession *> _sessions;
std::vector<HTTPSession *> _sessions_vec;
std::mutex _mutex;
protected:
static SessionManager *_self;
};
#endif