NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
Main Page
Related Pages
Modules
+
Namespaces
Namespace List
+
Namespace Members
+
All
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
y
z
+
Functions
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
w
+
Variables
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
+
Typedefs
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
y
+
Enumerations
a
b
c
d
f
i
k
l
n
p
q
r
s
t
u
v
+
Enumerator
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
z
+
Classes
Class List
Class Index
Class Hierarchy
+
Class Members
+
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
~
+
Functions
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
~
+
Variables
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
+
Typedefs
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
+
Enumerations
_
a
c
e
r
s
t
v
+
Enumerator
a
c
d
e
f
h
i
l
m
n
p
r
s
u
v
w
+
Related Functions
a
b
c
d
e
f
g
i
k
l
m
n
o
p
s
v
+
Files
File List
+
File Members
+
All
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
z
+
Functions
b
c
d
e
f
g
h
m
o
p
r
s
t
u
v
w
+
Variables
a
b
c
d
e
f
g
i
k
l
m
n
p
r
s
t
+
Typedefs
b
c
d
e
i
m
p
s
u
w
Enumerations
Enumerator
+
Macros
_
a
b
d
e
i
l
m
n
o
p
r
s
t
u
v
z
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Modules
Pages
subprotocol_server.cpp
Go to the documentation of this file.
1
#include <iostream>
2
3
#include <
websocketpp/config/asio_no_tls.hpp
>
4
#include <
websocketpp/server.hpp
>
5
6
typedef
websocketpp::server<websocketpp::config::asio>
server
;
7
8
using
websocketpp::connection_hdl
;
9
using
websocketpp::lib::placeholders::_1;
10
using
websocketpp::lib::placeholders::_2;
11
using
websocketpp::lib::bind;
12
using
websocketpp::lib::ref;
13
14
15
bool
validate
(
server
& s,
connection_hdl
hdl) {
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
}
33
34
int
main
() {
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
}
websocketpp::exception
Definition:
error.hpp:251
validate
bool validate(server &s, connection_hdl hdl)
Definition:
subprotocol_server.cpp:15
websocketpp::connection_hdl
lib::weak_ptr< void > connection_hdl
A handle to uniquely identify a connection.
Definition:
connection_hdl.hpp:48
websocketpp::endpoint::get_con_from_hdl
connection_ptr get_con_from_hdl(connection_hdl hdl, lib::error_code &ec)
Retrieves a connection_ptr from a connection_hdl (exception free)
Definition:
endpoint.hpp:643
server
websocketpp::server< websocketpp::config::asio > server
Definition:
subprotocol_server.cpp:6
websocketpp::server::start_accept
void start_accept(lib::error_code &ec)
Starts the server's async connection acceptance loop (exception free)
Definition:
server_endpoint.hpp:121
websocketpp::server< websocketpp::config::asio >
websocketpp::endpoint::set_validate_handler
void set_validate_handler(validate_handler h)
Definition:
endpoint.hpp:317
asio_no_tls.hpp
websocketpp::server< websocketpp::config::asio >::connection_ptr
connection_type::ptr connection_ptr
Type of a shared pointer to the connections this server will create.
Definition:
server_endpoint.hpp:57
main
int main()
Definition:
subprotocol_server.cpp:34
websocketpp::exception::what
virtual char const * what() const
Definition:
error.hpp:263
server.hpp
ndnSIM
NFD
websocketpp
examples
subprotocol_server
subprotocol_server.cpp
Generated on Fri May 6 2022 12:34:14 for ndnSIM by
1.8.13