]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/beast/websocket/teardown.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / beast / websocket / teardown.hpp
1 //
2 // Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
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 // Official repository: https://github.com/boostorg/beast
8 //
9
10 #ifndef BOOST_BEAST_WEBSOCKET_TEARDOWN_HPP
11 #define BOOST_BEAST_WEBSOCKET_TEARDOWN_HPP
12
13 #include <boost/beast/core/detail/config.hpp>
14 #include <boost/beast/core/error.hpp>
15 #include <boost/beast/websocket/role.hpp>
16 #include <boost/asio/ip/tcp.hpp>
17 #include <type_traits>
18
19 namespace boost {
20 namespace beast {
21 namespace websocket {
22
23 /** Tear down a connection.
24
25 This tears down a connection. The implementation will call
26 the overload of this function based on the `Socket` parameter
27 used to consruct the socket. When `Socket` is a user defined
28 type, and not a `boost::asio::ip::tcp::socket` or any
29 `boost::asio::ssl::stream`, callers are responsible for
30 providing a suitable overload of this function.
31
32 @param role The role of the local endpoint
33
34 @param socket The socket to tear down.
35
36 @param ec Set to the error if any occurred.
37 */
38 template<class Socket>
39 void
40 teardown(
41 role_type role,
42 Socket& socket,
43 error_code& ec)
44 {
45 boost::ignore_unused(role, socket, ec);
46 /*
47 If you are trying to use OpenSSL and this goes off, you need to
48 add an include for <boost/beast/websocket/ssl.hpp>.
49
50 If you are creating an instance of beast::websocket::stream with your
51 own user defined type, you must provide an overload of teardown with
52 the corresponding signature (including the role_type).
53 */
54 static_assert(sizeof(Socket)==-1,
55 "Unknown Socket type in teardown.");
56 }
57
58 /** Start tearing down a connection.
59
60 This begins tearing down a connection asynchronously.
61 The implementation will call the overload of this function
62 based on the `Socket` parameter used to consruct the socket.
63 When `Stream` is a user defined type, and not a
64 `boost::asio::ip::tcp::socket` or any `boost::asio::ssl::stream`,
65 callers are responsible for providing a suitable overload
66 of this function.
67
68 @param role The role of the local endpoint
69
70 @param socket The socket to tear down.
71
72 @param handler The handler to be called when the request completes.
73 Copies will be made of the handler as required. The equivalent
74 function signature of the handler must be:
75 @code void handler(
76 error_code const& error // result of operation
77 );
78 @endcode
79 Regardless of whether the asynchronous operation completes
80 immediately or not, the handler will not be invoked from within
81 this function. Invocation of the handler will be performed in a
82 manner equivalent to using boost::asio::io_context::post().
83
84 */
85 template<
86 class Socket,
87 class TeardownHandler>
88 void
89 async_teardown(
90 role_type role,
91 Socket& socket,
92 TeardownHandler&& handler)
93 {
94 boost::ignore_unused(role, socket, handler);
95 /*
96 If you are trying to use OpenSSL and this goes off, you need to
97 add an include for <boost/beast/websocket/ssl.hpp>.
98
99 If you are creating an instance of beast::websocket::stream with your
100 own user defined type, you must provide an overload of teardown with
101 the corresponding signature (including the role_type).
102 */
103 static_assert(sizeof(Socket)==-1,
104 "Unknown Socket type in async_teardown.");
105 }
106
107 } // websocket
108
109 //------------------------------------------------------------------------------
110
111 namespace websocket {
112
113 /** Tear down a `boost::asio::ip::tcp::socket`.
114
115 This tears down a connection. The implementation will call
116 the overload of this function based on the `Stream` parameter
117 used to consruct the socket. When `Stream` is a user defined
118 type, and not a `boost::asio::ip::tcp::socket` or any
119 `boost::asio::ssl::stream`, callers are responsible for
120 providing a suitable overload of this function.
121
122 @param role The role of the local endpoint
123
124 @param socket The socket to tear down.
125
126 @param ec Set to the error if any occurred.
127 */
128 void
129 teardown(
130 role_type role,
131 boost::asio::ip::tcp::socket& socket,
132 error_code& ec);
133
134 /** Start tearing down a `boost::asio::ip::tcp::socket`.
135
136 This begins tearing down a connection asynchronously.
137 The implementation will call the overload of this function
138 based on the `Stream` parameter used to consruct the socket.
139 When `Stream` is a user defined type, and not a
140 `boost::asio::ip::tcp::socket` or any `boost::asio::ssl::stream`,
141 callers are responsible for providing a suitable overload
142 of this function.
143
144 @param role The role of the local endpoint
145
146 @param socket The socket to tear down.
147
148 @param handler The handler to be called when the request completes.
149 Copies will be made of the handler as required. The equivalent
150 function signature of the handler must be:
151 @code void handler(
152 error_code const& error // result of operation
153 );
154 @endcode
155 Regardless of whether the asynchronous operation completes
156 immediately or not, the handler will not be invoked from within
157 this function. Invocation of the handler will be performed in a
158 manner equivalent to using boost::asio::io_context::post().
159
160 */
161 template<class TeardownHandler>
162 void
163 async_teardown(
164 role_type role,
165 boost::asio::ip::tcp::socket& socket,
166 TeardownHandler&& handler);
167
168 } // websocket
169 } // beast
170 } // boost
171
172 #include <boost/beast/websocket/impl/teardown.ipp>
173
174 #endif