websocket

reducing cpu % from 12% to 3%
this by adding this_thread sleep for 1ms
and moving sending of data to the process_messages thread
This commit is contained in:
2024-08-27 11:10:47 +02:00
parent ec93fd887c
commit bba27d9e86
2 changed files with 17 additions and 16 deletions
+4 -1
View File
@@ -19,17 +19,20 @@ using websocketpp::lib::placeholders::_2;
enum action_type {
SUBSCRIBE,
UNSUBSCRIBE,
MESSAGE
MESSAGE,
BROADCAST
};
struct action {
action(action_type t, websocketpp::connection_hdl h) : type(t), hdl(h) {}
action(action_type t, websocketpp::connection_hdl h, Server::message_ptr m)
: type(t), hdl(h), msg(m) {}
action(action_type t, std::string p) : type(t), payload(p) {}
action_type type;
websocketpp::connection_hdl hdl;
Server::message_ptr msg;
std::string payload;
};
class Websocket