rcpp_framework/core/http/session_manager.h

52 lines
1.1 KiB
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/string.h"
#include "core/containers/vector.h"
2021-08-04 21:02:34 +02:00
#include "core/object.h"
#include <map>
#include <mutex>
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 String &session_id);
void save_session(HTTPSession *session);
HTTPSession *get_session(const String &session_id);
2021-08-04 21:02:34 +02:00
HTTPSession *create_session();
void load_sessions();
2021-08-04 21:02:34 +02:00
void clear();
virtual String generate_session_id(const String &base = "");
2021-08-04 21:02:34 +02:00
static void session_setup_middleware(Object *instance, Request *request);
virtual void migrate();
virtual void create_table();
virtual void drop_table();
2021-08-04 21:02:34 +02:00
static SessionManager *get_singleton();
SessionManager();
~SessionManager();
std::map<String, HTTPSession *> _sessions;
Vector<HTTPSession *> _sessions_vec;
2021-08-04 21:02:34 +02:00
std::mutex _mutex;
protected:
static SessionManager *_self;
static String _table_name;
static String _data_table_name;
2021-08-04 21:02:34 +02:00
};
#endif