2022-06-25 01:55:54 +02:00
|
|
|
#ifndef WEB_SERVER_H
|
|
|
|
#define WEB_SERVER_H
|
|
|
|
|
2022-06-26 21:34:29 +02:00
|
|
|
#include "core/os/rw_lock.h"
|
|
|
|
#include "scene/main/node.h"
|
2022-06-25 01:55:54 +02:00
|
|
|
|
2022-06-26 21:34:29 +02:00
|
|
|
class WebServerRequest;
|
2022-06-25 01:55:54 +02:00
|
|
|
class WebNode;
|
2022-06-27 14:16:23 +02:00
|
|
|
class WebRoot;
|
|
|
|
class HTTPSessionManager;
|
2022-06-25 01:55:54 +02:00
|
|
|
|
2022-06-26 21:34:29 +02:00
|
|
|
class WebServer : public Node {
|
|
|
|
GDCLASS(WebServer, Node);
|
2022-06-25 01:55:54 +02:00
|
|
|
|
|
|
|
public:
|
2022-06-26 21:34:29 +02:00
|
|
|
NodePath get_web_root_path() const;
|
|
|
|
void set_web_root_path(const NodePath &path);
|
|
|
|
|
2022-06-25 01:55:54 +02:00
|
|
|
WebNode *get_web_root();
|
2022-06-26 21:34:29 +02:00
|
|
|
void set_web_root(WebNode *root);
|
2022-06-25 01:55:54 +02:00
|
|
|
|
2022-06-26 21:34:29 +02:00
|
|
|
Node *get_web_root_bind();
|
|
|
|
void set_web_root_bind(Node *root);
|
2022-06-25 01:55:54 +02:00
|
|
|
|
2022-06-27 14:16:23 +02:00
|
|
|
HTTPSessionManager *get_session_manager();
|
|
|
|
void set_session_manager(HTTPSessionManager *sess_man);
|
|
|
|
|
|
|
|
Node *get_session_manager_bind();
|
|
|
|
void set_session_manager_bind(Node *sess_man);
|
|
|
|
|
2022-06-27 01:03:01 +02:00
|
|
|
void server_handle_request(Ref<WebServerRequest> request);
|
2022-06-25 01:55:54 +02:00
|
|
|
|
2022-06-26 21:34:29 +02:00
|
|
|
void request_write_lock();
|
2022-06-25 01:55:54 +02:00
|
|
|
|
2022-06-27 14:16:23 +02:00
|
|
|
void start();
|
|
|
|
void stop();
|
|
|
|
|
|
|
|
virtual void _start();
|
|
|
|
virtual void _stop();
|
|
|
|
|
2022-06-25 01:55:54 +02:00
|
|
|
WebServer();
|
2022-06-26 21:34:29 +02:00
|
|
|
~WebServer();
|
2022-06-25 01:55:54 +02:00
|
|
|
|
|
|
|
protected:
|
2022-06-26 21:34:29 +02:00
|
|
|
static void _bind_methods();
|
|
|
|
|
|
|
|
NodePath _web_root_path;
|
2022-06-25 01:55:54 +02:00
|
|
|
WebNode *_web_root;
|
2022-06-26 21:34:29 +02:00
|
|
|
|
2022-06-27 14:16:23 +02:00
|
|
|
HTTPSessionManager *_session_manager;
|
|
|
|
|
2022-06-27 14:59:09 +02:00
|
|
|
//TODO this should be atomic
|
2022-06-26 21:34:29 +02:00
|
|
|
bool _write_lock_requested;
|
|
|
|
RWLock _rw_lock;
|
2022-06-25 01:55:54 +02:00
|
|
|
};
|
|
|
|
|
2022-06-26 21:34:29 +02:00
|
|
|
#endif
|