Blame view

3rdparty/boost_1_81_0/boost/beast/websocket/teardown.hpp 5.88 KB
63e88f80   Hu Chunming   提交三方库
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
  //
  // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
  //
  // Distributed under the Boost Software License, Version 1.0. (See accompanying
  // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  //
  // Official repository: https://github.com/boostorg/beast
  //
  
  #ifndef BOOST_BEAST_WEBSOCKET_TEARDOWN_HPP
  #define BOOST_BEAST_WEBSOCKET_TEARDOWN_HPP
  
  #include <boost/beast/core/detail/config.hpp>
  #include <boost/beast/core/error.hpp>
  #include <boost/beast/core/role.hpp>
  #include <boost/asio/basic_stream_socket.hpp>
  #include <type_traits>
  
  namespace boost {
  namespace beast {
  namespace websocket {
  
  /** Tear down a connection.
  
      This tears down a connection. The implementation will call
      the overload of this function based on the `Socket` parameter
      used to consruct the socket. When `Socket` is a user defined
      type, and not a `net::ip::tcp::socket` or any
      `net::ssl::stream`, callers are responsible for
      providing a suitable overload of this function.
  
      @param role The role of the local endpoint
  
      @param socket The socket to tear down.
  
      @param ec Set to the error if any occurred.
  */
  template<class Socket>
  void
  teardown(
      role_type role,
      Socket& socket,
      error_code& ec)
  {
      boost::ignore_unused(role, socket, ec);
  /*
      If you are trying to use OpenSSL and this goes off, you need to
      add an include for <boost/beast/websocket/ssl.hpp>.
  
      If you are creating an instance of beast::websocket::stream with your
      own user defined type, you must provide an overload of teardown with
      the corresponding signature (including the role_type).
  */
      static_assert(sizeof(Socket)==-1,
          "Unknown Socket type in teardown.");
  }
  
  /** Start tearing down a connection.
  
      This begins tearing down a connection asynchronously.
      The implementation will call the overload of this function
      based on the `Socket` parameter used to consruct the socket.
      When `Stream` is a user defined type, and not a
      `net::ip::tcp::socket` or any `net::ssl::stream`,
      callers are responsible for providing a suitable overload
      of this function.
  
      @param role The role of the local endpoint
  
      @param socket The socket to tear down.
  
      @param handler The completion handler to invoke when the operation
      completes. The implementation takes ownership of the handler by
      performing a decay-copy. The equivalent function signature of
      the handler must be:
      @code
      void handler(
          error_code const& error // result of operation
      );
      @endcode
      Regardless of whether the asynchronous operation completes
      immediately or not, the handler will not be invoked from within
      this function. Invocation of the handler will be performed in a
      manner equivalent to using `net::post`.
  
  */
  template<
      class Socket,
      class TeardownHandler>
  void
  async_teardown(
      role_type role,
      Socket& socket,
      TeardownHandler&& handler)
  {
      boost::ignore_unused(role, socket, handler);
  /*
      If you are trying to use OpenSSL and this goes off, you need to
      add an include for <boost/beast/websocket/ssl.hpp>.
  
      If you are creating an instance of beast::websocket::stream with your
      own user defined type, you must provide an overload of teardown with
      the corresponding signature (including the role_type).
  */
      static_assert(sizeof(Socket)==-1,
          "Unknown Socket type in async_teardown.");
  }
  
  } // websocket
  
  //------------------------------------------------------------------------------
  
  namespace websocket {
  
  /** Tear down a `net::ip::tcp::socket`.
  
      This tears down a connection. The implementation will call
      the overload of this function based on the `Stream` parameter
      used to consruct the socket. When `Stream` is a user defined
      type, and not a `net::ip::tcp::socket` or any
      `net::ssl::stream`, callers are responsible for
      providing a suitable overload of this function.
  
      @param role The role of the local endpoint
  
      @param socket The socket to tear down.
  
      @param ec Set to the error if any occurred.
  */
  template<class Protocol, class Executor>
  void
  teardown(
      role_type role,
      net::basic_stream_socket<
          Protocol, Executor>& socket,
      error_code& ec);
  
  /** Start tearing down a `net::ip::tcp::socket`.
  
      This begins tearing down a connection asynchronously.
      The implementation will call the overload of this function
      based on the `Stream` parameter used to consruct the socket.
      When `Stream` is a user defined type, and not a
      `net::ip::tcp::socket` or any `net::ssl::stream`,
      callers are responsible for providing a suitable overload
      of this function.
  
      @param role The role of the local endpoint
  
      @param socket The socket to tear down.
  
      @param handler The completion handler to invoke when the operation
      completes. The implementation takes ownership of the handler by
      performing a decay-copy. The equivalent function signature of
      the handler must be:
      @code
      void handler(
          error_code const& error // result of operation
      );
      @endcode   
      Regardless of whether the asynchronous operation completes
      immediately or not, the handler will not be invoked from within
      this function. Invocation of the handler will be performed in a
      manner equivalent to using `net::post`.
  
      @par Per-Operation Cancellation
  
      This asynchronous operation supports cancellation for the following
      net::cancellation_type values:
  
      @li @c net::cancellation_type::terminal
      @li @c net::cancellation_type::partial
      @li @c net::cancellation_type::total
  
      if they are also supported by the socket's @c async_wait operation.
  
  */
  template<
      class Protocol, class Executor,
      class TeardownHandler>
  void
  async_teardown(
      role_type role,
      net::basic_stream_socket<
          Protocol, Executor>& socket,
      TeardownHandler&& handler);
  
  } // websocket
  } // beast
  } // boost
  
  #include <boost/beast/websocket/impl/teardown.hpp>
  
  #endif