mirror of
https://github.com/Relintai/rcpp_framework.git
synced 2025-05-06 17:51:36 +02:00
Added an update interval setting to the web server. Also update will get called if it's > 0.
This commit is contained in:
parent
26d161fd26
commit
e705cbca34
@ -28,6 +28,7 @@ void WebServer::handle_request(Request *request) {
|
|||||||
|
|
||||||
WebServer::WebServer() : NodeTree() {
|
WebServer::WebServer() : NodeTree() {
|
||||||
_web_root = nullptr;
|
_web_root = nullptr;
|
||||||
|
_update_interval = 0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
WebServer::~WebServer() {
|
WebServer::~WebServer() {
|
||||||
|
@ -21,7 +21,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
WebNode *_web_root;
|
WebNode *_web_root;
|
||||||
|
float _update_interval;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -12,8 +12,8 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "core/net/tcp_connection.h"
|
|
||||||
#include "core/log/async_file_logger.h"
|
#include "core/log/async_file_logger.h"
|
||||||
|
#include "core/net/tcp_connection.h"
|
||||||
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
@ -209,6 +209,14 @@ void DrogonWebServer::run() {
|
|||||||
_beginning_advices.clear();
|
_beginning_advices.clear();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (_update_interval > 0) {
|
||||||
|
get_loop()->runEvery(_update_interval, [this]() {
|
||||||
|
this->update();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
get_loop()->loop();
|
get_loop()->loop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user