diff --git a/modules/web/http/http_session_manager.cpp b/modules/web/http/http_session_manager.cpp index 932299837..6da16b52f 100644 --- a/modules/web/http/http_session_manager.cpp +++ b/modules/web/http/http_session_manager.cpp @@ -15,9 +15,9 @@ #include "web_server_cookie.h" -void SessionManager::add_session(Ref &session) { +void HTTPSessionManager::add_session(Ref &session) { if (!session.is_valid()) { - printf("SessionManager::add_session: ERROR, session is null!\n"); + printf("HTTPSessionManager::add_session: ERROR, session is null!\n"); return; } @@ -29,9 +29,9 @@ void SessionManager::add_session(Ref &session) { _mutex.unlock(); } -void SessionManager::remove_session(Ref &session) { +void HTTPSessionManager::remove_session(Ref &session) { if (!session.is_valid()) { - printf("SessionManager::remove_session: ERROR, session is null!\n"); + printf("HTTPSessionManager::remove_session: ERROR, session is null!\n"); return; } @@ -51,7 +51,7 @@ void SessionManager::remove_session(Ref &session) { _mutex.unlock(); } -void SessionManager::delete_session(const String &session_id) { +void HTTPSessionManager::delete_session(const String &session_id) { _mutex.lock(); Ref s = _sessions[session_id]; @@ -88,7 +88,7 @@ void SessionManager::delete_session(const String &session_id) { #endif } -void SessionManager::save_session(Ref &session) { +void HTTPSessionManager::save_session(Ref &session) { #if DATABASES_ENABLED Ref b = DatabaseManager::get_singleton()->ddb->get_query_builder(); @@ -121,11 +121,11 @@ void SessionManager::save_session(Ref &session) { #endif } -Ref SessionManager::get_session(const String &session_id) { +Ref HTTPSessionManager::get_session(const String &session_id) { return _sessions[session_id]; } -Ref SessionManager::create_session() { +Ref HTTPSessionManager::create_session() { Ref session = new HTTPSession(); while (true) { @@ -150,7 +150,7 @@ Ref SessionManager::create_session() { return session; } -void SessionManager::load_sessions() { +void HTTPSessionManager::load_sessions() { clear(); #if DATABASES_ENABLED @@ -195,7 +195,7 @@ void SessionManager::load_sessions() { } if (!s.is_valid()) { - printf("Error: SessionManager::load_sessions(): %d sid doesn't exists!\n", session_db_id); + printf("Error: HTTPSessionManager::load_sessions(): %d sid doesn't exists!\n", session_db_id); continue; } @@ -208,7 +208,7 @@ void SessionManager::load_sessions() { #endif } -void SessionManager::clear() { +void HTTPSessionManager::clear() { _mutex.lock(); _sessions.clear(); @@ -217,7 +217,7 @@ void SessionManager::clear() { _mutex.unlock(); } -String SessionManager::generate_session_id(const String &base) { +String HTTPSessionManager::generate_session_id(const String &base) { // todo make something simpler / better String sid = base; @@ -227,12 +227,12 @@ String SessionManager::generate_session_id(const String &base) { return sid.sha256_text().substr(0, 20); } -void SessionManager::migrate() { +void HTTPSessionManager::migrate() { drop_table(); create_table(); } -void SessionManager::create_table() { +void HTTPSessionManager::create_table() { #if DATABASES_ENABLED Ref tb = DatabaseManager::get_singleton()->ddb->get_table_builder(); @@ -257,7 +257,7 @@ void SessionManager::create_table() { tb->run_query(); #endif } -void SessionManager::drop_table() { +void HTTPSessionManager::drop_table() { #if DATABASES_ENABLED Ref tb = DatabaseManager::get_singleton()->ddb->get_table_builder(); @@ -266,16 +266,16 @@ void SessionManager::drop_table() { #endif } -SessionManager::SessionManager() { +HTTPSessionManager::HTTPSessionManager() { _table_name = "sessions"; _data_table_name = "session_data"; } -SessionManager::~SessionManager() { +HTTPSessionManager::~HTTPSessionManager() { clear(); } -void SessionManager::_bind_methods() { +void HTTPSessionManager::_bind_methods() { } bool SessionSetupWebServerMiddleware::_on_before_handle_request_main(Ref request) { @@ -284,7 +284,7 @@ bool SessionSetupWebServerMiddleware::_on_before_handle_request_main(Refcreate_session(); + // HTTPSession *session = HTTPSessionManager::get_singleton()->create_session(); // request->session = session; // request->add_cookie(::Cookie("session_id", session->session_id)); @@ -297,12 +297,12 @@ bool SessionSetupWebServerMiddleware::_on_before_handle_request_main(Ref maybe webroot node should not be auto discovered, it should have a nodepath for safety // I - WebRoot // I - WebNodes ... (site) - // I - SessionManager (finds parent websercver, registers itself in enter tree) + // I - HTTPSessionManager (finds parent websercver, registers itself in enter tree) // I - Other helper nodes, maybe a DatabaseManager (convert to node) etc These will not be accessible //request->server->get_session_manager()->get_session(sid); - //request->session = SessionManager::get_singleton()->get_session(sid); + //request->session = HTTPSessionManager::get_singleton()->get_session(sid); return false; } diff --git a/modules/web/http/http_session_manager.h b/modules/web/http/http_session_manager.h index b5e80cb81..8eb3d9304 100644 --- a/modules/web/http/http_session_manager.h +++ b/modules/web/http/http_session_manager.h @@ -14,8 +14,8 @@ class HTTPSession; class WebServerRequest; -class SessionManager : public Node { - GDCLASS(SessionManager, Node); +class HTTPSessionManager : public Node { + GDCLASS(HTTPSessionManager, Node); public: void add_session(Ref &session); @@ -35,8 +35,8 @@ public: virtual void create_table(); virtual void drop_table(); - SessionManager(); - ~SessionManager(); + HTTPSessionManager(); + ~HTTPSessionManager(); HashMap> _sessions; Vector> _sessions_vec;