| 26 | using tcp = boost::asio::ip::tcp; |
| 27 | |
| 28 | void |
| 29 | testIdlePing() |
| 30 | { |
| 31 | net::io_context ioc; |
| 32 | |
| 33 | // idle ping, no timeout |
| 34 | |
| 35 | { |
| 36 | stream<tcp::socket> ws1(ioc); |
| 37 | stream<tcp::socket> ws2(ioc); |
| 38 | test::connect(ws1.next_layer(), ws2.next_layer()); |
| 39 | ws1.async_accept(test::success_handler()); |
| 40 | ws2.async_handshake("test", "/", test::success_handler()); |
| 41 | test::run(ioc); |
| 42 | |
| 43 | ws2.set_option(stream_base::timeout{ |
| 44 | stream_base::none(), |
| 45 | std::chrono::milliseconds(200), |
| 46 | true}); |
| 47 | flat_buffer b1; |
| 48 | flat_buffer b2; |
| 49 | bool received = false; |
| 50 | ws1.control_callback( |
| 51 | [&received](frame_type ft, string_view) |
| 52 | { |
| 53 | received = true; |
| 54 | BEAST_EXPECT(ft == frame_type::ping); |
| 55 | }); |
| 56 | ws1.async_read(b1, test::fail_handler( |
| 57 | net::error::operation_aborted)); |
| 58 | ws2.async_read(b2, test::fail_handler( |
| 59 | net::error::operation_aborted)); |
| 60 | test::run_for(ioc, std::chrono::milliseconds(500)); |
| 61 | BEAST_EXPECT(received); |
| 62 | } |
| 63 | |
| 64 | test::run(ioc); |
| 65 | |
| 66 | // idle ping, timeout |
| 67 | |
| 68 | { |
| 69 | stream<tcp::socket> ws1(ioc); |
| 70 | stream<tcp::socket> ws2(ioc); |
| 71 | test::connect(ws1.next_layer(), ws2.next_layer()); |
| 72 | ws1.async_accept(test::success_handler()); |
| 73 | ws2.async_handshake("test", "/", test::success_handler()); |
| 74 | test::run(ioc); |
| 75 | |
| 76 | ws2.set_option(stream_base::timeout{ |
| 77 | stream_base::none(), |
| 78 | std::chrono::milliseconds(50), |
| 79 | true}); |
| 80 | flat_buffer b; |
| 81 | ws2.async_read(b, |
| 82 | test::fail_handler(beast::error::timeout)); |
| 83 | test::run(ioc); |
| 84 | } |
| 85 |
nothing calls this directly
no test coverage detected