diff --git a/tools/websocket.cpp b/tools/websocket.cpp index 9beffb1..3be4708 100644 --- a/tools/websocket.cpp +++ b/tools/websocket.cpp @@ -117,15 +117,6 @@ void Websocket::process_messages() m_server.send(a.hdl, response, websocketpp::frame::opcode::TEXT); } break; - case BROADCAST: - { - std::lock_guard guard(m_connection_lock); - for (auto it : m_connections) - { - m_server.send(it, a.payload, websocketpp::frame::opcode::TEXT); - } - } - break; default: break; } @@ -143,9 +134,11 @@ void Websocket::process_broadcast() continue; } { - std::lock_guard guard(m_action_lock); - m_actions.push(action(BROADCAST, update)); + std::lock_guard guard(m_connection_lock); + for (auto it : m_connections) + { + m_server.send(it, update, websocketpp::frame::opcode::TEXT); + } } - m_action_cond.notify_one(); } } \ No newline at end of file diff --git a/tools/websocket.hpp b/tools/websocket.hpp index b65760d..2410274 100644 --- a/tools/websocket.hpp +++ b/tools/websocket.hpp @@ -27,12 +27,10 @@ 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