2021-08-04 20:32:51 +02:00
|
|
|
|
|
|
|
#include "http_session.h"
|
|
|
|
|
2021-11-01 19:11:27 +01:00
|
|
|
void HTTPSession::add_object(const String &key, Object *obj) {
|
2021-08-04 20:32:51 +02:00
|
|
|
std::lock_guard<std::mutex> lock(_mutex);
|
|
|
|
|
|
|
|
_data[key] = obj;
|
|
|
|
}
|
2021-11-01 19:11:27 +01:00
|
|
|
void HTTPSession::remove_object(const String &key) {
|
2021-08-04 20:32:51 +02:00
|
|
|
std::lock_guard<std::mutex> lock(_mutex);
|
|
|
|
|
|
|
|
_data.erase(key);
|
|
|
|
}
|
2021-11-01 19:11:27 +01:00
|
|
|
Object *HTTPSession::get_object(const String &key) {
|
2021-08-04 20:32:51 +02:00
|
|
|
//don't lock here
|
|
|
|
|
|
|
|
return _data[key];
|
|
|
|
}
|
|
|
|
|
2021-11-01 19:11:27 +01:00
|
|
|
void HTTPSession::add_reference(const String &key, const Ref<Reference> &ref) {
|
2021-08-22 22:03:10 +02:00
|
|
|
std::lock_guard<std::mutex> lock(_mutex);
|
|
|
|
|
|
|
|
_reference_data[key] = ref;
|
|
|
|
}
|
2021-11-01 19:11:27 +01:00
|
|
|
void HTTPSession::remove_reference(const String &key) {
|
2021-08-22 22:03:10 +02:00
|
|
|
std::lock_guard<std::mutex> lock(_mutex);
|
|
|
|
|
|
|
|
_reference_data.erase(key);
|
|
|
|
}
|
2021-11-01 19:11:27 +01:00
|
|
|
Ref<Reference> HTTPSession::get_reference(const String &key) {
|
2021-08-22 22:03:10 +02:00
|
|
|
//don't lock here
|
|
|
|
|
|
|
|
return _reference_data[key];
|
|
|
|
}
|
|
|
|
|
2021-11-01 19:11:27 +01:00
|
|
|
void HTTPSession::add_int(const String &key, const int val) {
|
2021-08-04 20:32:51 +02:00
|
|
|
std::lock_guard<std::mutex> lock(_mutex);
|
|
|
|
|
|
|
|
_int_data[key] = val;
|
|
|
|
}
|
2021-11-01 19:11:27 +01:00
|
|
|
void HTTPSession::remove_int(const String &key) {
|
2021-08-04 20:32:51 +02:00
|
|
|
std::lock_guard<std::mutex> lock(_mutex);
|
|
|
|
|
|
|
|
_int_data.erase(key);
|
|
|
|
}
|
2021-11-01 19:11:27 +01:00
|
|
|
int HTTPSession::get_int(const String &key) {
|
2021-08-04 20:32:51 +02:00
|
|
|
//don't lock here
|
|
|
|
|
|
|
|
return _int_data[key];
|
|
|
|
}
|
|
|
|
|
|
|
|
void HTTPSession::clear() {
|
|
|
|
_data.clear();
|
|
|
|
_int_data.clear();
|
2021-08-22 22:03:10 +02:00
|
|
|
_reference_data.clear();
|
2021-08-04 20:32:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void HTTPSession::reset() {
|
|
|
|
clear();
|
|
|
|
session_id = "";
|
|
|
|
}
|
|
|
|
|
2021-11-01 19:11:27 +01:00
|
|
|
std::map<String, int> HTTPSession::get_int_data() {
|
2021-08-22 23:53:26 +02:00
|
|
|
return _int_data;
|
|
|
|
}
|
|
|
|
|
2021-08-04 20:32:51 +02:00
|
|
|
HTTPSession::HTTPSession() {
|
2021-08-22 23:53:26 +02:00
|
|
|
id = 0;
|
2021-08-04 20:32:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
HTTPSession::~HTTPSession() {
|
|
|
|
clear();
|
|
|
|
}
|