2021-07-07 12:20:05 +02:00
|
|
|
#include "user.h"
|
|
|
|
|
2021-08-04 21:29:19 +02:00
|
|
|
#include "core/http/http_session.h"
|
|
|
|
#include "core/http/session_manager.h"
|
2021-08-03 21:10:24 +02:00
|
|
|
|
2021-08-04 21:29:19 +02:00
|
|
|
void User::save() {
|
2021-08-03 21:10:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void User::load() {
|
2021-08-04 21:29:19 +02:00
|
|
|
//unregister_sessions()
|
|
|
|
//load_code
|
|
|
|
//register_sessions()
|
2021-08-03 21:10:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void User::load(const std::string &p_name) {
|
|
|
|
name = p_name;
|
|
|
|
|
|
|
|
load();
|
|
|
|
}
|
|
|
|
|
|
|
|
void User::changed() {
|
|
|
|
save();
|
|
|
|
}
|
|
|
|
|
|
|
|
void User::update() {
|
2021-08-04 21:29:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void User::register_sessions() {
|
|
|
|
if (sessions.size() == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
SessionManager *sm = SessionManager::get_singleton();
|
|
|
|
|
|
|
|
if (!sm) {
|
|
|
|
printf("ERROR: UserManager::add_user SessionManager singleton is null, please allocate one!\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < sessions.size(); ++i) {
|
|
|
|
HTTPSession *session = new HTTPSession();
|
|
|
|
session->session_id = sessions[i];
|
|
|
|
session->add_object("user", this);
|
|
|
|
|
|
|
|
sm->add_session(session);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void User::unregister_sessions() {
|
|
|
|
if (sessions.size() == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
SessionManager *sm = SessionManager::get_singleton();
|
|
|
|
|
|
|
|
if (!sm) {
|
|
|
|
printf("ERROR: UserManager::remove_user SessionManager singleton is null, please allocate one!\n");
|
|
|
|
return;
|
|
|
|
}
|
2021-08-03 21:10:24 +02:00
|
|
|
|
2021-08-04 21:29:19 +02:00
|
|
|
for (int i = 0; i < sessions.size(); ++i) {
|
|
|
|
sm->delete_session(sessions[i]);
|
|
|
|
}
|
2021-08-03 21:10:24 +02:00
|
|
|
}
|
|
|
|
|
2021-07-07 12:20:05 +02:00
|
|
|
User::User() :
|
|
|
|
Object() {
|
|
|
|
|
2021-08-03 21:10:24 +02:00
|
|
|
id = 0;
|
|
|
|
rank = 0;
|
|
|
|
banned = false;
|
|
|
|
locked = false;
|
2021-07-07 12:20:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
User::~User() {
|
2021-08-04 21:29:19 +02:00
|
|
|
unregister_sessions();
|
2021-07-07 12:20:05 +02:00
|
|
|
}
|