ssl.hpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. //
  2. // Copyright (c) 2016-2019 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. #ifndef BOOST_BEAST_WEBSOCKET_SSL_HPP
  10. #define BOOST_BEAST_WEBSOCKET_SSL_HPP
  11. #include <boost/beast/core/detail/config.hpp>
  12. #include <boost/beast/websocket/teardown.hpp>
  13. #include <boost/asio/ip/tcp.hpp>
  14. #include <boost/asio/ssl/stream.hpp>
  15. namespace boost {
  16. namespace beast {
  17. /** Tear down a `net::ssl::stream`.
  18. This tears down a connection. The implementation will call
  19. the overload of this function based on the `Stream` parameter
  20. used to consruct the socket. When `Stream` is a user defined
  21. type, and not a `net::ip::tcp::socket` or any
  22. `net::ssl::stream`, callers are responsible for
  23. providing a suitable overload of this function.
  24. @note
  25. This function serves as a customization point and is not intended
  26. to be called directly.
  27. @param role The role of the local endpoint
  28. @param stream The stream to tear down.
  29. @param ec Set to the error if any occurred.
  30. */
  31. template<class SyncStream>
  32. void
  33. teardown(
  34. role_type role,
  35. net::ssl::stream<SyncStream>& stream,
  36. error_code& ec);
  37. /** Start tearing down a `net::ssl::stream`.
  38. This begins tearing down a connection asynchronously.
  39. The implementation will call the overload of this function
  40. based on the `Stream` parameter used to consruct the socket.
  41. When `Stream` is a user defined type, and not a
  42. `net::ip::tcp::socket` or any `net::ssl::stream`,
  43. callers are responsible for providing a suitable overload
  44. of this function.
  45. @note
  46. This function serves as a customization point and is not intended
  47. to be called directly.
  48. @param role The role of the local endpoint
  49. @param stream The stream to tear down.
  50. @param handler The completion handler to invoke when the operation
  51. completes. The implementation takes ownership of the handler by
  52. performing a decay-copy. The equivalent function signature of
  53. the handler must be:
  54. @code
  55. void handler(
  56. error_code const& error // result of operation
  57. );
  58. @endcode
  59. If the handler has an associated immediate executor,
  60. an immediate completion will be dispatched to it.
  61. Otherwise, the handler will not be invoked from within
  62. this function. Invocation of the handler will be performed in a
  63. manner equivalent to using `net::post`.
  64. @par Per-Operation Cancellation
  65. This asynchronous operation supports cancellation for the following
  66. net::cancellation_type values:
  67. @li @c net::cancellation_type::terminal
  68. @li @c net::cancellation_type::partial
  69. @li @c net::cancellation_type::total
  70. if they are also supported by the socket's @c async_teardown
  71. and @c async_shutdown operation.
  72. */
  73. template<class AsyncStream, class TeardownHandler>
  74. void
  75. async_teardown(
  76. role_type role,
  77. net::ssl::stream<AsyncStream>& stream,
  78. TeardownHandler&& handler);
  79. } // beast
  80. } // boost
  81. #include <boost/beast/websocket/impl/ssl.hpp>
  82. #endif