36 static void initialize(bs::websocket::stream<NextLayer>& stream) {
39 bs::websocket::stream_base::decorator(
40 [](bs::websocket::request_type& req) {
41 req.set(
"Sec-WebSocket-Protocol",
"mqtt");
50 typename ConstBufferSequence,
51 typename CompletionToken
55 bs::websocket::stream<NextLayer>& stream,
56 ConstBufferSequence
const& cbs,
57 CompletionToken&& token
59 return as::async_compose<
63 async_write_impl<ConstBufferSequence>{
72 template <
typename ConstBufferSequence>
73 struct async_write_impl {
74 bs::websocket::stream<NextLayer>& stream;
75 ConstBufferSequence
const& cbs;
77 template <
typename Self>
87 template <
typename Self>
93 self.complete(ec, size);
100 typename CompletionToken
104 bs::websocket::stream<NextLayer>& stream,
105 CompletionToken&& token
107 return as::async_compose<
119 struct async_close_impl {
120 bs::websocket::stream<NextLayer>& stream;
122 template <
typename Self>
127 bs::websocket::close_code::none,
132 template <
typename Self>
141 auto buffer = std::make_shared<bs::flat_buffer>();
152 template <
typename Self>
159 if (ec == bs::websocket::error::closed) {
160 ASYNC_MQTT_LOG(
"mqtt_impl",
info)
161 <<
"ws async_read (for close) success";
164 ASYNC_MQTT_LOG(
"mqtt_impl",
info)
165 <<
"ws async_read (for close):" << ec.message();
170 auto buffer = std::make_shared<bs::flat_buffer>();