rcpp_framework/web/http/http_session.cpp

66 lines
1.1 KiB
C++
Raw Normal View History

2021-08-04 20:32:51 +02:00
#include "http_session.h"
void HTTPSession::add(const String &key, const Variant &value) {
_mutex.lock();
2021-08-04 20:32:51 +02:00
_data[key] = value;
_mutex.unlock();
2021-08-04 20:32:51 +02:00
}
void HTTPSession::remove(const String &key) {
_mutex.lock();
_data[key] = Variant();
2021-08-04 20:32:51 +02:00
_mutex.unlock();
}
bool HTTPSession::has(const String &key) {
2022-01-09 15:48:54 +01:00
return !_data[key].is_null();
2021-08-04 20:32:51 +02:00
}
Variant HTTPSession::get(const String &key) {
2021-08-04 20:32:51 +02:00
return _data[key];
}
2022-01-09 14:51:04 +01:00
const Variant &HTTPSession::get_const(const String &key) {
return _data[key];
}
2021-08-04 20:32:51 +02:00
Object *HTTPSession::get_object(const String &key) {
// don't lock here
return _data[key].to_object();
}
Ref<Reference> HTTPSession::get_reference(const String &key) {
// don't lock here
return _data[key].to_reference();
}
int HTTPSession::get_int(const String &key) {
// don't lock here
2021-08-04 20:32:51 +02:00
return _data[key].to_int();
2021-08-04 20:32:51 +02:00
}
void HTTPSession::clear() {
_data.clear();
}
void HTTPSession::reset() {
clear();
session_id = "";
}
std::map<String, Variant> *HTTPSession::get_data() {
return &_data;
}
2021-08-04 20:32:51 +02:00
HTTPSession::HTTPSession() {
id = 0;
2021-08-04 20:32:51 +02:00
}
HTTPSession::~HTTPSession() {
clear();
}