Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
testee_server.cpp File Reference
Include dependency graph for testee_server.cpp:

Go to the source code of this file.

Classes

struct  testee_config
 
struct  testee_config::transport_config
 
struct  testee_config::permessage_deflate_config
 permessage_compress extension More...
 

Typedefs

typedef websocketpp::server< testee_configserver
 

Functions

void on_message (server *s, websocketpp::connection_hdl hdl, message_ptr msg)
 
void on_socket_init (websocketpp::connection_hdl, boost::asio::ip::tcp::socket &s)
 
int main (int argc, char *argv[])
 

Typedef Documentation

◆ server

Definition at line 76 of file testee_server.cpp.

Function Documentation

◆ main()

int main ( int argc,
char * argv[] )

Definition at line 95 of file testee_server.cpp.

95 {
96 // Create a server endpoint
97 server testee_server;
98
99 short port = 9002;
100 size_t num_threads = 1;
101
102 if (argc == 3) {
103 port = atoi(argv[1]);
104 num_threads = atoi(argv[2]);
105 }
106
107 try {
108 // Total silence
111
112 // Initialize ASIO
113 testee_server.init_asio();
114 testee_server.set_reuse_addr(true);
115
116 // Register our message handler
117 testee_server.set_message_handler(bind(&on_message,&testee_server,::_1,::_2));
118 testee_server.set_socket_init_handler(bind(&on_socket_init,::_1,::_2));
119
120 // Listen on specified port with extended listen backlog
121 testee_server.set_listen_backlog(8192);
122 testee_server.listen(port);
123
124 // Start the server accept loop
125 testee_server.start_accept();
126
127 // Start the ASIO io_service run loop
128 if (num_threads == 1) {
129 testee_server.run();
130 } else {
131 typedef websocketpp::lib::shared_ptr<websocketpp::lib::thread> thread_ptr;
132 std::vector<thread_ptr> ts;
133 for (size_t i = 0; i < num_threads; i++) {
134 ts.push_back(websocketpp::lib::make_shared<websocketpp::lib::thread>(&server::run, &testee_server));
135 }
136
137 for (size_t i = 0; i < num_threads; i++) {
138 ts[i]->join();
139 }
140 }
141
142 } catch (websocketpp::exception const & e) {
143 std::cout << "exception: " << e.what() << std::endl;
144 }
145}
void set_message_handler(message_handler h)
Definition endpoint.hpp:322
void clear_access_channels(log::level channels)
Clear Access logging channels.
Definition endpoint.hpp:231
void clear_error_channels(log::level channels)
Clear Error logging channels.
Definition endpoint.hpp:253
virtual char const * what() const
Definition error.hpp:263
void start_accept(lib::error_code &ec)
Starts the server's async connection acceptance loop (exception free)
char ** argv
static level const all
Special aggregate value representing "all levels".
Definition levels.hpp:152
void on_socket_init(websocketpp::connection_hdl, boost::asio::ip::tcp::socket &s)
void on_message(server *s, websocketpp::connection_hdl hdl, message_ptr msg)
Here is the call graph for this function:

◆ on_message()

void on_message ( server * s,
websocketpp::connection_hdl hdl,
message_ptr msg )

Definition at line 86 of file testee_server.cpp.

86 {
87 s->send(hdl, msg->get_payload(), msg->get_opcode());
88}
char * s
Here is the caller graph for this function:

◆ on_socket_init()

void on_socket_init ( websocketpp::connection_hdl ,
boost::asio::ip::tcp::socket & s )

Definition at line 90 of file testee_server.cpp.

90 {
91 boost::asio::ip::tcp::no_delay option(true);
92 s.set_option(option);
93}
yh_option option
Definition yubihsm.h:685
Here is the caller graph for this function: