ssl.hpp 2.9 KB

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