mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-02-06 16:16:06 +01:00
Cleaned up HTTPSession.
This commit is contained in:
parent
0b0d5e3657
commit
da266fbea2
@ -1,6 +1,20 @@
|
|||||||
|
|
||||||
#include "http_session.h"
|
#include "http_session.h"
|
||||||
|
|
||||||
|
String HTTPSession::get_session_id() {
|
||||||
|
return session_id;
|
||||||
|
}
|
||||||
|
void HTTPSession::set_session_id(const String &val) {
|
||||||
|
session_id = val;
|
||||||
|
}
|
||||||
|
|
||||||
|
int HTTPSession::get_id() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
void HTTPSession::set_id(const int val) {
|
||||||
|
id = val;
|
||||||
|
}
|
||||||
|
|
||||||
void HTTPSession::add(const String &key, const Variant &value) {
|
void HTTPSession::add(const String &key, const Variant &value) {
|
||||||
_mutex.lock();
|
_mutex.lock();
|
||||||
|
|
||||||
@ -19,7 +33,7 @@ bool HTTPSession::has(const String &key) {
|
|||||||
return !_data[key].is_null();
|
return !_data[key].is_null();
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant HTTPSession::get(const String &key) {
|
Variant HTTPSession::get_value(const String &key) {
|
||||||
return _data[key];
|
return _data[key];
|
||||||
}
|
}
|
||||||
const Variant &HTTPSession::get_const(const String &key) {
|
const Variant &HTTPSession::get_const(const String &key) {
|
||||||
@ -29,19 +43,19 @@ const Variant &HTTPSession::get_const(const String &key) {
|
|||||||
Object *HTTPSession::get_object(const String &key) {
|
Object *HTTPSession::get_object(const String &key) {
|
||||||
// don't lock here
|
// don't lock here
|
||||||
|
|
||||||
return _data[key].to_object();
|
return _data[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<Reference> HTTPSession::get_reference(const String &key) {
|
Ref<Reference> HTTPSession::get_reference(const String &key) {
|
||||||
// don't lock here
|
// don't lock here
|
||||||
|
|
||||||
return _data[key].to_reference();
|
return Ref<Reference>(_data[key]);
|
||||||
}
|
}
|
||||||
|
|
||||||
int HTTPSession::get_int(const String &key) {
|
int HTTPSession::get_int(const String &key) {
|
||||||
// don't lock here
|
// don't lock here
|
||||||
|
|
||||||
return _data[key].to_int();
|
return _data[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
void HTTPSession::clear() {
|
void HTTPSession::clear() {
|
||||||
@ -53,7 +67,7 @@ void HTTPSession::reset() {
|
|||||||
session_id = "";
|
session_id = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::map<String, Variant> *HTTPSession::get_data() {
|
HashMap<String, Variant> *HTTPSession::get_data() {
|
||||||
return &_data;
|
return &_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,3 +78,21 @@ HTTPSession::HTTPSession() {
|
|||||||
HTTPSession::~HTTPSession() {
|
HTTPSession::~HTTPSession() {
|
||||||
clear();
|
clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HTTPSession::_bind_methods() {
|
||||||
|
ClassDB::bind_method(D_METHOD("get_session_id"), &HTTPSession::get_session_id);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_session_id", "val"), &HTTPSession::set_session_id);
|
||||||
|
ADD_PROPERTY(PropertyInfo(Variant::STRING, "session_id"), "set_session_id", "get_session_id");
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("get_id"), &HTTPSession::get_id);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_id", "val"), &HTTPSession::set_id);
|
||||||
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "id"), "set_id", "get_id");
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("add", "key", "value"), &HTTPSession::add);
|
||||||
|
ClassDB::bind_method(D_METHOD("remove", "key"), &HTTPSession::remove);
|
||||||
|
ClassDB::bind_method(D_METHOD("has", "key"), &HTTPSession::has);
|
||||||
|
ClassDB::bind_method(D_METHOD("get_value", "key"), &HTTPSession::get_value);
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("clear"), &HTTPSession::clear);
|
||||||
|
ClassDB::bind_method(D_METHOD("reset"), &HTTPSession::reset);
|
||||||
|
}
|
||||||
|
@ -1,44 +1,51 @@
|
|||||||
#ifndef HTTP_SESSION_H
|
#ifndef HTTP_SESSION_H
|
||||||
#define HTTP_SESSION_H
|
#define HTTP_SESSION_H
|
||||||
|
|
||||||
#include <map>
|
#include "core/hash_map.h"
|
||||||
|
|
||||||
#include "core/reference.h"
|
#include "core/reference.h"
|
||||||
|
|
||||||
#include "core/string.h"
|
#include "core/os/mutex.h"
|
||||||
|
#include "core/ustring.h"
|
||||||
#include "core/variant.h"
|
#include "core/variant.h"
|
||||||
#include "core/threading/mutex.h"
|
|
||||||
|
|
||||||
|
|
||||||
class HTTPSession : public Reference {
|
class HTTPSession : public Reference {
|
||||||
RCPP_OBJECT(HTTPSession, Reference);
|
GDCLASS(HTTPSession, Reference);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
String get_session_id();
|
||||||
|
void set_session_id(const String &val);
|
||||||
|
|
||||||
|
int get_id();
|
||||||
|
void set_id(const int val);
|
||||||
|
|
||||||
void add(const String &key, const Variant &value);
|
void add(const String &key, const Variant &value);
|
||||||
void remove(const String &key);
|
void remove(const String &key);
|
||||||
bool has(const String &key);
|
bool has(const String &key);
|
||||||
|
Variant get_value(const String &key);
|
||||||
|
|
||||||
Variant get(const String &key);
|
|
||||||
const Variant &get_const(const String &key);
|
const Variant &get_const(const String &key);
|
||||||
Object *get_object(const String &key);
|
Object *get_object(const String &key);
|
||||||
Ref<Reference> get_reference(const String &key);
|
Ref<Reference> get_reference(const String &key);
|
||||||
int get_int(const String &key);
|
int get_int(const String &key);
|
||||||
|
|
||||||
String session_id;
|
|
||||||
int id;
|
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
std::map<String, Variant> *get_data();
|
HashMap<String, Variant> *get_data();
|
||||||
|
|
||||||
HTTPSession();
|
HTTPSession();
|
||||||
~HTTPSession();
|
~HTTPSession();
|
||||||
|
|
||||||
|
String session_id;
|
||||||
|
int id;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
static void _bind_methods();
|
||||||
|
|
||||||
Mutex _mutex;
|
Mutex _mutex;
|
||||||
|
|
||||||
std::map<String, Variant> _data;
|
HashMap<String, Variant> _data;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
Loading…
Reference in New Issue
Block a user