![]() |
|
|||
File indexing completed on 2025-07-01 08:09:39
0001 // 0002 // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) 0003 // 0004 // Distributed under the Boost Software License, Version 1.0. (See accompanying 0005 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 0006 // 0007 // Official repository: https://github.com/boostorg/beast 0008 // 0009 0010 #ifndef BOOST_BEAST_WEBSOCKET_TEARDOWN_HPP 0011 #define BOOST_BEAST_WEBSOCKET_TEARDOWN_HPP 0012 0013 #include <boost/beast/core/detail/config.hpp> 0014 #include <boost/beast/core/error.hpp> 0015 #include <boost/beast/core/role.hpp> 0016 #include <boost/asio/basic_stream_socket.hpp> 0017 #include <type_traits> 0018 0019 namespace boost { 0020 namespace beast { 0021 namespace websocket { 0022 0023 /** Tear down a connection. 0024 0025 This tears down a connection. The implementation will call 0026 the overload of this function based on the `Socket` parameter 0027 used to consruct the socket. When `Socket` is a user defined 0028 type, and not a `net::ip::tcp::socket` or any 0029 `net::ssl::stream`, callers are responsible for 0030 providing a suitable overload of this function. 0031 0032 @note 0033 0034 This function serves as a customization point and is not intended 0035 to be called directly. 0036 0037 @param role The role of the local endpoint 0038 0039 @param socket The socket to tear down. 0040 0041 @param ec Set to the error if any occurred. 0042 */ 0043 template<class Socket> 0044 void 0045 teardown( 0046 role_type role, 0047 Socket& socket, 0048 error_code& ec) 0049 { 0050 boost::ignore_unused(role, socket, ec); 0051 /* 0052 If you are trying to use OpenSSL and this goes off, you need to 0053 add an include for <boost/beast/websocket/ssl.hpp>. 0054 0055 If you are creating an instance of beast::websocket::stream with your 0056 own user defined type, you must provide an overload of teardown with 0057 the corresponding signature (including the role_type). 0058 */ 0059 static_assert(sizeof(Socket)==-1, 0060 "Unknown Socket type in teardown."); 0061 } 0062 0063 /** Start tearing down a connection. 0064 0065 This begins tearing down a connection asynchronously. 0066 The implementation will call the overload of this function 0067 based on the `Socket` parameter used to consruct the socket. 0068 When `Stream` is a user defined type, and not a 0069 `net::ip::tcp::socket` or any `net::ssl::stream`, 0070 callers are responsible for providing a suitable overload 0071 of this function. 0072 0073 @note 0074 0075 This function serves as a customization point and is not intended 0076 to be called directly. 0077 0078 @param role The role of the local endpoint 0079 0080 @param socket The socket to tear down. 0081 0082 @param handler The completion handler to invoke when the operation 0083 completes. The implementation takes ownership of the handler by 0084 performing a decay-copy. The equivalent function signature of 0085 the handler must be: 0086 @code 0087 void handler( 0088 error_code const& error // result of operation 0089 ); 0090 @endcode 0091 If the handler has an associated immediate executor, 0092 an immediate completion will be dispatched to it. 0093 Otherwise, the handler will not be invoked from within 0094 this function. Invocation of the handler will be performed in a 0095 manner equivalent to using `net::post`. 0096 0097 */ 0098 template< 0099 class Socket, 0100 class TeardownHandler> 0101 void 0102 async_teardown( 0103 role_type role, 0104 Socket& socket, 0105 TeardownHandler&& handler) 0106 { 0107 boost::ignore_unused(role, socket, handler); 0108 /* 0109 If you are trying to use OpenSSL and this goes off, you need to 0110 add an include for <boost/beast/websocket/ssl.hpp>. 0111 0112 If you are creating an instance of beast::websocket::stream with your 0113 own user defined type, you must provide an overload of teardown with 0114 the corresponding signature (including the role_type). 0115 */ 0116 static_assert(sizeof(Socket)==-1, 0117 "Unknown Socket type in async_teardown."); 0118 } 0119 0120 } // websocket 0121 0122 //------------------------------------------------------------------------------ 0123 0124 namespace websocket { 0125 0126 /** Tear down a `net::ip::tcp::socket`. 0127 0128 This tears down a connection. The implementation will call 0129 the overload of this function based on the `Stream` parameter 0130 used to consruct the socket. When `Stream` is a user defined 0131 type, and not a `net::ip::tcp::socket` or any 0132 `net::ssl::stream`, callers are responsible for 0133 providing a suitable overload of this function. 0134 0135 @note 0136 0137 This function serves as a customization point and is not intended 0138 to be called directly. 0139 0140 @param role The role of the local endpoint 0141 0142 @param socket The socket to tear down. 0143 0144 @param ec Set to the error if any occurred. 0145 */ 0146 template<class Protocol, class Executor> 0147 void 0148 teardown( 0149 role_type role, 0150 net::basic_stream_socket< 0151 Protocol, Executor>& socket, 0152 error_code& ec); 0153 0154 /** Start tearing down a `net::ip::tcp::socket`. 0155 0156 This begins tearing down a connection asynchronously. 0157 The implementation will call the overload of this function 0158 based on the `Stream` parameter used to consruct the socket. 0159 When `Stream` is a user defined type, and not a 0160 `net::ip::tcp::socket` or any `net::ssl::stream`, 0161 callers are responsible for providing a suitable overload 0162 of this function. 0163 0164 @note 0165 0166 This function serves as a customization point and is not intended 0167 to be called directly. 0168 0169 @param role The role of the local endpoint 0170 0171 @param socket The socket to tear down. 0172 0173 @param handler The completion handler to invoke when the operation 0174 completes. The implementation takes ownership of the handler by 0175 performing a decay-copy. The equivalent function signature of 0176 the handler must be: 0177 @code 0178 void handler( 0179 error_code const& error // result of operation 0180 ); 0181 @endcode 0182 If the handler has an associated immediate executor, 0183 an immediate completion will be dispatched to it. 0184 Otherwise, the handler will not be invoked from within 0185 this function. Invocation of the handler will be performed in a 0186 manner equivalent to using `net::post`. 0187 0188 @par Per-Operation Cancellation 0189 0190 This asynchronous operation supports cancellation for the following 0191 net::cancellation_type values: 0192 0193 @li @c net::cancellation_type::terminal 0194 @li @c net::cancellation_type::partial 0195 @li @c net::cancellation_type::total 0196 0197 if they are also supported by the socket's @c async_wait operation. 0198 0199 */ 0200 template< 0201 class Protocol, class Executor, 0202 class TeardownHandler> 0203 void 0204 async_teardown( 0205 role_type role, 0206 net::basic_stream_socket< 0207 Protocol, Executor>& socket, 0208 TeardownHandler&& handler); 0209 0210 } // websocket 0211 } // beast 0212 } // boost 0213 0214 #include <boost/beast/websocket/impl/teardown.hpp> 0215 0216 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |