| 1 | // |
| 2 | // Copyright (c) 2023 Mohammad Nejati |
| 3 | // |
| 4 | // Distributed under the Boost Software License, Version 1.0. (See accompanying |
| 5 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
| 6 | // |
| 7 | |
| 8 | #include <boost/asio/deferred.hpp> |
| 9 | #include <boost/asio/ip/tcp.hpp> |
| 10 | #include <boost/beast/websocket.hpp> |
| 11 | |
| 12 | using namespace boost; |
| 13 | namespace websocket = boost::beast::websocket; |
| 14 | |
| 15 | #if !defined(BOOST_NO_CXX14) |
| 16 | |
| 17 | // just compile this. |
| 18 | void test_deferred_for_websocket( |
| 19 | websocket::stream<asio::ip::tcp::socket> & stream, |
| 20 | beast::flat_static_buffer_base & buf, |
| 21 | beast::http::request<beast::http::empty_body> & req, |
| 22 | websocket::response_type & res) |
| 23 | { |
| 24 | (void)stream.async_accept(handler: asio::deferred); |
| 25 | (void)stream.async_accept(buffers: asio::const_buffer(), handler: asio::deferred); |
| 26 | (void)stream.async_accept(req, handler: asio::deferred); |
| 27 | (void)stream.async_close(cr: websocket::close_code::bad_payload, handler: asio::deferred); |
| 28 | |
| 29 | (void)stream.async_handshake(host: "" , target: "/" , handler: asio::deferred); |
| 30 | (void)stream.async_handshake(res, host: "" , target: "/" , handler: asio::deferred); |
| 31 | |
| 32 | (void)stream.async_ping(payload: websocket::ping_data{}, handler: asio::deferred); |
| 33 | (void)stream.async_pong(payload: websocket::ping_data{}, handler: asio::deferred); |
| 34 | |
| 35 | (void)stream.async_read(buffer&: buf, handler: asio::deferred); |
| 36 | (void)stream.async_read_some(buffers: buf.data(), handler: asio::deferred); |
| 37 | |
| 38 | (void)stream.async_write(bs: buf.cdata(), handler: asio::deferred); |
| 39 | (void)stream.async_write_some(fin: true, bs: buf.cdata(), handler: asio::deferred); |
| 40 | } |
| 41 | |
| 42 | #endif |
| 43 | |