MCPcopy Create free account
hub / github.com/boostorg/beast / do_sync_session

Function do_sync_session

example/websocket/server/fast/websocket_server_fast.cpp:82–115  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

80//------------------------------------------------------------------------------
81
82void
83do_sync_session(websocket::stream<beast::tcp_stream>& ws)
84{
85 beast::error_code ec;
86
87 setup_stream(ws);
88
89 // Set a decorator to change the Server of the handshake
90 ws.set_option(websocket::stream_base::decorator(
91 [](websocket::response_type& res)
92 {
93 res.set(http::field::server, std::string(
94 BOOST_BEAST_VERSION_STRING) + "-Sync");
95 }));
96
97 ws.accept(ec);
98 if(ec)
99 return fail(ec, "accept");
100
101 for(;;)
102 {
103 beast::flat_buffer buffer;
104
105 ws.read(buffer, ec);
106 if(ec == websocket::error::closed)
107 break;
108 if(ec)
109 return fail(ec, "read");
110 ws.text(ws.got_text());
111 ws.write(buffer.data(), ec);
112 if(ec)
113 return fail(ec, "write");
114 }
115}
116
117void
118do_sync_listen(

Callers

nothing calls this directly

Calls 9

setup_streamFunction · 0.85
set_optionMethod · 0.80
textMethod · 0.80
failFunction · 0.70
decoratorClass · 0.50
acceptMethod · 0.45
readMethod · 0.45
writeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected