mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-05-09 23:31:36 +02:00
Hode session_id and id in HTTPSession.
This commit is contained in:
parent
7937fb6cae
commit
5aa9a0db10
@ -117,14 +117,14 @@ Ref<HTTPSession> HTTPSessionManagerDB::delete_session(const String &session_id)
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!s->id) {
|
if (!s->get_id()) {
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<QueryBuilder> b = get_query_builder();
|
Ref<QueryBuilder> b = get_query_builder();
|
||||||
|
|
||||||
b->del(_database_data_table_name)->where()->wpi("session_db_id", s->id)->end_command();
|
b->del(_database_data_table_name)->where()->wpi("session_db_id", s->get_id())->end_command();
|
||||||
b->del(_database_table_name)->where()->wpi("id", s->id)->end_command();
|
b->del(_database_table_name)->where()->wpi("id", s->get_id())->end_command();
|
||||||
b->run_query();
|
b->run_query();
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
@ -133,21 +133,21 @@ Ref<HTTPSession> HTTPSessionManagerDB::delete_session(const String &session_id)
|
|||||||
void HTTPSessionManagerDB::save_session(Ref<HTTPSession> session) {
|
void HTTPSessionManagerDB::save_session(Ref<HTTPSession> session) {
|
||||||
Ref<QueryBuilder> b = get_query_builder();
|
Ref<QueryBuilder> b = get_query_builder();
|
||||||
|
|
||||||
if (!session->id) {
|
if (!session->get_id()) {
|
||||||
b->insert(_database_table_name, "session_id");
|
b->insert(_database_table_name, "session_id");
|
||||||
b->values();
|
b->values();
|
||||||
b->vals(session->session_id);
|
b->vals(session->get_session_id());
|
||||||
b->cvalues();
|
b->cvalues();
|
||||||
b->end_command();
|
b->end_command();
|
||||||
b->select_last_insert_id();
|
b->select_last_insert_id();
|
||||||
|
|
||||||
session->id = b->run()->get_last_insert_rowid();
|
session->set_id(b->run()->get_last_insert_rowid());
|
||||||
|
|
||||||
b->reset();
|
b->reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
b->del(_database_data_table_name)->where()->wpi("session_db_id", session->id)->end_command();
|
b->del(_database_data_table_name)->where()->wpi("session_db_id", session->get_id())->end_command();
|
||||||
int id = session->id;
|
int id = session->get_id();
|
||||||
|
|
||||||
HashMap<String, Variant> *m = session->get_data();
|
HashMap<String, Variant> *m = session->get_data();
|
||||||
|
|
||||||
@ -188,9 +188,9 @@ void HTTPSessionManagerDB::load_sessions() {
|
|||||||
|
|
||||||
Ref<HTTPSession> s;
|
Ref<HTTPSession> s;
|
||||||
s.instance();
|
s.instance();
|
||||||
s->id = id;
|
s->set_id(id);
|
||||||
|
|
||||||
s->session_id = session_id;
|
s->set_session_id(session_id);
|
||||||
|
|
||||||
add_session(s);
|
add_session(s);
|
||||||
}
|
}
|
||||||
@ -210,7 +210,7 @@ void HTTPSessionManagerDB::load_sessions() {
|
|||||||
for (int i = 0; i < _sessions_vec.size(); ++i) {
|
for (int i = 0; i < _sessions_vec.size(); ++i) {
|
||||||
Ref<HTTPSession> ss = _sessions_vec[i];
|
Ref<HTTPSession> ss = _sessions_vec[i];
|
||||||
|
|
||||||
if (ss.is_valid() && session_db_id == ss->id) {
|
if (ss.is_valid() && session_db_id == ss->get_id()) {
|
||||||
s = ss;
|
s = ss;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -77,12 +77,12 @@ public:
|
|||||||
HTTPSession();
|
HTTPSession();
|
||||||
~HTTPSession();
|
~HTTPSession();
|
||||||
|
|
||||||
String session_id;
|
|
||||||
int id;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
|
|
||||||
|
String session_id;
|
||||||
|
int id;
|
||||||
|
|
||||||
Mutex _mutex;
|
Mutex _mutex;
|
||||||
|
|
||||||
HashMap<String, Variant> _data;
|
HashMap<String, Variant> _data;
|
||||||
|
@ -50,7 +50,7 @@ void HTTPSessionManager::add_session(Ref<HTTPSession> session) {
|
|||||||
_mutex.lock();
|
_mutex.lock();
|
||||||
|
|
||||||
_sessions_vec.push_back(session);
|
_sessions_vec.push_back(session);
|
||||||
_sessions[session->session_id] = session;
|
_sessions[session->get_session_id()] = session;
|
||||||
|
|
||||||
_mutex.unlock();
|
_mutex.unlock();
|
||||||
}
|
}
|
||||||
@ -60,7 +60,7 @@ void HTTPSessionManager::remove_session(Ref<HTTPSession> session) {
|
|||||||
|
|
||||||
_mutex.lock();
|
_mutex.lock();
|
||||||
|
|
||||||
_sessions.erase(session->session_id);
|
_sessions.erase(session->get_session_id());
|
||||||
|
|
||||||
for (int i = 0; i < _sessions_vec.size(); ++i) {
|
for (int i = 0; i < _sessions_vec.size(); ++i) {
|
||||||
if (_sessions_vec[i] == session) {
|
if (_sessions_vec[i] == session) {
|
||||||
@ -83,7 +83,7 @@ Ref<HTTPSession> HTTPSessionManager::delete_session(const String &session_id) {
|
|||||||
for (int i = 0; i < _sessions_vec.size(); ++i) {
|
for (int i = 0; i < _sessions_vec.size(); ++i) {
|
||||||
Ref<HTTPSession> sess = _sessions_vec[i];
|
Ref<HTTPSession> sess = _sessions_vec[i];
|
||||||
|
|
||||||
if (sess->session_id == session_id) {
|
if (sess->get_session_id() == session_id) {
|
||||||
_sessions_vec.remove(i);
|
_sessions_vec.remove(i);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -107,13 +107,13 @@ Ref<HTTPSession> HTTPSessionManager::create_session() {
|
|||||||
session.instance();
|
session.instance();
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
session->session_id = generate_session_id(session->session_id);
|
session->set_session_id(generate_session_id(session->get_session_id()));
|
||||||
|
|
||||||
_mutex.lock();
|
_mutex.lock();
|
||||||
|
|
||||||
if (_sessions[session->session_id] == nullptr) {
|
if (_sessions[session->get_session_id()] == nullptr) {
|
||||||
_sessions_vec.push_back(session);
|
_sessions_vec.push_back(session);
|
||||||
_sessions[session->session_id] = session;
|
_sessions[session->get_session_id()] = session;
|
||||||
|
|
||||||
_mutex.unlock();
|
_mutex.unlock();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user