Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
count_server Class Reference

Public Member Functions

 count_server ()
 
void on_open (connection_hdl hdl)
 
void on_close (connection_hdl hdl)
 
void count ()
 
void run (uint16_t port)
 

Detailed Description

Definition at line 13 of file simple_count_server_thread.cpp.

Constructor & Destructor Documentation

◆ count_server()

count_server::count_server ( )
inline

Definition at line 15 of file simple_count_server_thread.cpp.

15 : m_count(0) {
16 m_server.init_asio();
17
18 m_server.set_open_handler(bind(&count_server::on_open,this,_1));
19 m_server.set_close_handler(bind(&count_server::on_close,this,_1));
20 }
void on_open(connection_hdl hdl)
void on_close(connection_hdl hdl)
void set_open_handler(open_handler h)
Definition endpoint.hpp:277
void set_close_handler(close_handler h)
Definition endpoint.hpp:282
Here is the call graph for this function:

Member Function Documentation

◆ count()

void count_server::count ( )
inline

Definition at line 32 of file simple_count_server_thread.cpp.

32 {
33 while (1) {
34 sleep(1);
35 m_count++;
36
37 std::stringstream ss;
38 ss << m_count;
39
40 std::lock_guard<std::mutex> lock(m_mutex);
41 for (auto it : m_connections) {
42 m_server.send(it,ss.str(),websocketpp::frame::opcode::text);
43 }
44 }
45 }
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)
static const Segment ss(Segment::ss)
void lock()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ on_close()

void count_server::on_close ( connection_hdl hdl)
inline

Definition at line 27 of file simple_count_server_thread.cpp.

27 {
28 std::lock_guard<std::mutex> lock(m_mutex);
29 m_connections.erase(hdl);
30 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ on_open()

void count_server::on_open ( connection_hdl hdl)
inline

Definition at line 22 of file simple_count_server_thread.cpp.

22 {
23 std::lock_guard<std::mutex> lock(m_mutex);
24 m_connections.insert(hdl);
25 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ run()

void count_server::run ( uint16_t port)
inline

Definition at line 47 of file simple_count_server_thread.cpp.

47 {
48 m_server.listen(port);
49 m_server.start_accept();
50 m_server.run();
51 }
void start_accept(lib::error_code &ec)
Starts the server's async connection acceptance loop (exception free)
Here is the call graph for this function:

The documentation for this class was generated from the following file: