Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
subprotocol_server.cpp File Reference
#include <iostream>
#include <websocketpp/config/asio_no_tls.hpp>
#include <websocketpp/server.hpp>
Include dependency graph for subprotocol_server.cpp:

Go to the source code of this file.

Typedefs

typedef websocketpp::server< websocketpp::config::asioserver
 

Functions

bool validate (server &s, connection_hdl hdl)
 
int main ()
 

Typedef Documentation

◆ server

Function Documentation

◆ main()

int main ( void )

Definition at line 34 of file subprotocol_server.cpp.

34 {
35 try {
36 server s;
37
38 s.set_validate_handler(bind(&validate,ref(s),::_1));
39
40 s.init_asio();
41 s.listen(9005);
42 s.start_accept();
43
44 s.run();
45 } catch (websocketpp::exception const & e) {
46 std::cout << e.what() << std::endl;
47 }
48}
void set_validate_handler(validate_handler h)
Definition endpoint.hpp:317
virtual char const * what() const
Definition error.hpp:263
bool validate(server &s, connection_hdl hdl)
char * s
Here is the call graph for this function:

◆ validate()

bool validate ( server & s,
connection_hdl hdl )

Definition at line 15 of file subprotocol_server.cpp.

15 {
16 server::connection_ptr con = s.get_con_from_hdl(hdl);
17
18 std::cout << "Cache-Control: " << con->get_request_header("Cache-Control") << std::endl;
19
20 const std::vector<std::string> & subp_requests = con->get_requested_subprotocols();
21 std::vector<std::string>::const_iterator it;
22
23 for (it = subp_requests.begin(); it != subp_requests.end(); ++it) {
24 std::cout << "Requested: " << *it << std::endl;
25 }
26
27 if (subp_requests.size() > 0) {
28 con->select_subprotocol(subp_requests[0]);
29 }
30
31 return true;
32}
Here is the call graph for this function:
Here is the caller graph for this function: