Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:29:35

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     @param role The role of the local endpoint
0033 
0034     @param socket The socket to tear down.
0035 
0036     @param ec Set to the error if any occurred.
0037 */
0038 template<class Socket>
0039 void
0040 teardown(
0041     role_type role,
0042     Socket& socket,
0043     error_code& ec)
0044 {
0045     boost::ignore_unused(role, socket, ec);
0046 /*
0047     If you are trying to use OpenSSL and this goes off, you need to
0048     add an include for <boost/beast/websocket/ssl.hpp>.
0049 
0050     If you are creating an instance of beast::websocket::stream with your
0051     own user defined type, you must provide an overload of teardown with
0052     the corresponding signature (including the role_type).
0053 */
0054     static_assert(sizeof(Socket)==-1,
0055         "Unknown Socket type in teardown.");
0056 }
0057 
0058 /** Start tearing down a connection.
0059 
0060     This begins tearing down a connection asynchronously.
0061     The implementation will call the overload of this function
0062     based on the `Socket` parameter used to consruct the socket.
0063     When `Stream` is a user defined type, and not a
0064     `net::ip::tcp::socket` or any `net::ssl::stream`,
0065     callers are responsible for providing a suitable overload
0066     of this function.
0067 
0068     @param role The role of the local endpoint
0069 
0070     @param socket The socket to tear down.
0071 
0072     @param handler The completion handler to invoke when the operation
0073     completes. The implementation takes ownership of the handler by
0074     performing a decay-copy. The equivalent function signature of
0075     the handler must be:
0076     @code
0077     void handler(
0078         error_code const& error // result of operation
0079     );
0080     @endcode
0081     If the handler has an associated immediate executor,
0082     an immediate completion will be dispatched to it.
0083     Otherwise, the handler will not be invoked from within
0084     this function. Invocation of the handler will be performed in a
0085     manner equivalent to using `net::post`.
0086 
0087 */
0088 template<
0089     class Socket,
0090     class TeardownHandler>
0091 void
0092 async_teardown(
0093     role_type role,
0094     Socket& socket,
0095     TeardownHandler&& handler)
0096 {
0097     boost::ignore_unused(role, socket, handler);
0098 /*
0099     If you are trying to use OpenSSL and this goes off, you need to
0100     add an include for <boost/beast/websocket/ssl.hpp>.
0101 
0102     If you are creating an instance of beast::websocket::stream with your
0103     own user defined type, you must provide an overload of teardown with
0104     the corresponding signature (including the role_type).
0105 */
0106     static_assert(sizeof(Socket)==-1,
0107         "Unknown Socket type in async_teardown.");
0108 }
0109 
0110 } // websocket
0111 
0112 //------------------------------------------------------------------------------
0113 
0114 namespace websocket {
0115 
0116 /** Tear down a `net::ip::tcp::socket`.
0117 
0118     This tears down a connection. The implementation will call
0119     the overload of this function based on the `Stream` parameter
0120     used to consruct the socket. When `Stream` is a user defined
0121     type, and not a `net::ip::tcp::socket` or any
0122     `net::ssl::stream`, callers are responsible for
0123     providing a suitable overload of this function.
0124 
0125     @param role The role of the local endpoint
0126 
0127     @param socket The socket to tear down.
0128 
0129     @param ec Set to the error if any occurred.
0130 */
0131 template<class Protocol, class Executor>
0132 void
0133 teardown(
0134     role_type role,
0135     net::basic_stream_socket<
0136         Protocol, Executor>& socket,
0137     error_code& ec);
0138 
0139 /** Start tearing down a `net::ip::tcp::socket`.
0140 
0141     This begins tearing down a connection asynchronously.
0142     The implementation will call the overload of this function
0143     based on the `Stream` parameter used to consruct the socket.
0144     When `Stream` is a user defined type, and not a
0145     `net::ip::tcp::socket` or any `net::ssl::stream`,
0146     callers are responsible for providing a suitable overload
0147     of this function.
0148 
0149     @param role The role of the local endpoint
0150 
0151     @param socket The socket to tear down.
0152 
0153     @param handler The completion handler to invoke when the operation
0154     completes. The implementation takes ownership of the handler by
0155     performing a decay-copy. The equivalent function signature of
0156     the handler must be:
0157     @code
0158     void handler(
0159         error_code const& error // result of operation
0160     );
0161     @endcode   
0162     If the handler has an associated immediate executor,
0163     an immediate completion will be dispatched to it.
0164     Otherwise, the handler will not be invoked from within
0165     this function. Invocation of the handler will be performed in a
0166     manner equivalent to using `net::post`.
0167 
0168     @par Per-Operation Cancellation
0169 
0170     This asynchronous operation supports cancellation for the following
0171     net::cancellation_type values:
0172 
0173     @li @c net::cancellation_type::terminal
0174     @li @c net::cancellation_type::partial
0175     @li @c net::cancellation_type::total
0176 
0177     if they are also supported by the socket's @c async_wait operation.
0178 
0179 */
0180 template<
0181     class Protocol, class Executor,
0182     class TeardownHandler>
0183 void
0184 async_teardown(
0185     role_type role,
0186     net::basic_stream_socket<
0187         Protocol, Executor>& socket,
0188     TeardownHandler&& handler);
0189 
0190 } // websocket
0191 } // beast
0192 } // boost
0193 
0194 #include <boost/beast/websocket/impl/teardown.hpp>
0195 
0196 #endif