Definition at line 13 of file simple_broadcast_server.cpp.
◆ broadcast_server() [1/3]
broadcast_server::broadcast_server |
( |
| ) |
|
|
inline |
Definition at line 15 of file simple_broadcast_server.cpp.
15 {
16 m_server.init_asio();
17
21 }
void on_open(connection_hdl hdl)
void on_message(connection_hdl hdl, server::message_ptr msg)
void on_close(connection_hdl hdl)
void set_message_handler(message_handler h)
void set_open_handler(open_handler h)
void set_close_handler(close_handler h)
◆ broadcast_server() [2/3]
broadcast_server::broadcast_server |
( |
| ) |
|
|
inline |
◆ broadcast_server() [3/3]
broadcast_server::broadcast_server |
( |
| ) |
|
|
inline |
◆ on_close() [1/3]
◆ on_close() [2/3]
Definition at line 83 of file broadcast_server.cpp.
83 {
84 {
85 lock_guard<mutex> guard(m_action_lock);
86
88 }
89 m_action_cond.notify_one();
90 }
◆ on_close() [3/3]
◆ on_message() [1/3]
Definition at line 31 of file simple_broadcast_server.cpp.
31 {
32 for (auto it : m_connections) {
33 m_server.
send(it,msg);
34 }
35 }
void send(connection_hdl hdl, std::string const &payload, frame::opcode::value op, lib::error_code &ec)
Create a message and add it to the outgoing send queue (exception free)
◆ on_message() [2/3]
Definition at line 92 of file broadcast_server.cpp.
92 {
93
94 {
95 lock_guard<mutex> guard(m_action_lock);
96
98 }
99 m_action_cond.notify_one();
100 }
◆ on_message() [3/3]
◆ on_open() [1/3]
◆ on_open() [2/3]
Definition at line 74 of file broadcast_server.cpp.
74 {
75 {
76 lock_guard<mutex> guard(m_action_lock);
77
79 }
80 m_action_cond.notify_one();
81 }
◆ on_open() [3/3]
◆ process_messages()
void broadcast_server::process_messages |
( |
| ) |
|
|
inline |
Definition at line 102 of file broadcast_server.cpp.
102 {
103 while(1) {
104 unique_lock<mutex>
lock(m_action_lock);
105
106 while(m_actions.empty()) {
107 m_action_cond.wait(lock);
108 }
109
111 m_actions.pop();
112
113 lock.unlock();
114
116 lock_guard<mutex> guard(m_connection_lock);
117 m_connections.insert(
a.hdl);
119 lock_guard<mutex> guard(m_connection_lock);
120 m_connections.erase(
a.hdl);
122 lock_guard<mutex> guard(m_connection_lock);
123
124 con_list::iterator it;
125 for (it = m_connections.begin(); it != m_connections.end(); ++it) {
126 m_server.
send(*it,
a.msg);
127 }
128 } else {
129
130 }
131 }
132 }
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
◆ run() [1/3]
void broadcast_server::run |
( |
uint16_t | port | ) |
|
|
inline |
Definition at line 37 of file simple_broadcast_server.cpp.
37 {
38 m_server.listen(port);
40 m_server.run();
41 }
void start_accept(lib::error_code &ec)
Starts the server's async connection acceptance loop (exception free)
◆ run() [2/3]
void broadcast_server::run |
( |
uint16_t | port | ) |
|
|
inline |
Definition at line 59 of file broadcast_server.cpp.
59 {
60
61 m_server.listen(port);
62
63
65
66
67 try {
68 m_server.run();
69 } catch (const std::exception & e) {
70 std::cout << e.what() << std::endl;
71 }
72 }
◆ run() [3/3]
void broadcast_server::run |
( |
uint16_t | port | ) |
|
|
inline |
The documentation for this class was generated from the following files: