ssl.hpp 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. #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. namespace websocket {
  18. /** Tear down a `boost::asio::ssl::stream`.
  19. This tears down a connection. The implementation will call
  20. the overload of this function based on the `Stream` parameter
  21. used to consruct the socket. When `Stream` is a user defined
  22. type, and not a `boost::asio::ip::tcp::socket` or any
  23. `boost::asio::ssl::stream`, callers are responsible for
  24. providing a suitable overload of this function.
  25. @param role The role of the local endpoint
  26. @param stream The stream to tear down.
  27. @param ec Set to the error if any occurred.
  28. */
  29. template<class SyncStream>
  30. void
  31. teardown(
  32. role_type role,
  33. boost::asio::ssl::stream<SyncStream>& stream,
  34. error_code& ec);
  35. /** Start tearing down a `boost::asio::ssl::stream`.
  36. This begins tearing down a connection asynchronously.
  37. The implementation will call the overload of this function
  38. based on the `Stream` parameter used to consruct the socket.
  39. When `Stream` is a user defined type, and not a
  40. `boost::asio::ip::tcp::socket` or any `boost::asio::ssl::stream`,
  41. callers are responsible for providing a suitable overload
  42. of this function.
  43. @param role The role of the local endpoint
  44. @param stream The stream to tear down.
  45. @param handler Invoked when the operation completes.
  46. The handler may be moved or copied as needed.
  47. The equivalent function signature of the handler must be:
  48. @code void handler(
  49. error_code const& error // result of operation
  50. ); @endcode
  51. Regardless of whether the asynchronous operation completes
  52. immediately or not, the handler will not be invoked from within
  53. this function. Invocation of the handler will be performed in a
  54. manner equivalent to using boost::asio::io_context::post().
  55. */
  56. template<class AsyncStream, class TeardownHandler>
  57. inline
  58. void
  59. async_teardown(
  60. role_type role,
  61. boost::asio::ssl::stream<AsyncStream>& stream,
  62. TeardownHandler&& handler);
  63. } // websocket
  64. } // beast
  65. } // boost
  66. #include <boost/beast/websocket/impl/ssl.ipp>
  67. #endif