role.hpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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_ROLE_HPP
  10. #define BOOST_BEAST_WEBSOCKET_ROLE_HPP
  11. #include <boost/beast/core/detail/config.hpp>
  12. namespace boost {
  13. namespace beast {
  14. namespace websocket {
  15. /** The role of the websocket stream endpoint.
  16. Whether the endpoint is a client or server affects the
  17. behavior of the <em>Close the WebSocket Connection</em>
  18. operation described in rfc6455 section 7.1.1.
  19. The shutdown behavior depends on the type of the next
  20. layer template parameter used to construct the @ref stream.
  21. Other next layer types including user-defined types
  22. may implement different role-based behavior when
  23. performing the close operation.
  24. The default implementation for @ref stream when the next
  25. layer type is a `boost::asio::ip::tcp::socket` behaves
  26. as follows:
  27. @li In the client role, a TCP/IP shutdown is sent after
  28. reading all remaining data on the connection.
  29. @li In the server role, a TCP/IP shutdown is sent before
  30. reading all remaining data on the connection.
  31. When the next layer type is a `boost::asio::ssl::stream`,
  32. the connection is closed by performing the SSL closing
  33. handshake corresponding to the role type, client or server.
  34. @see https://tools.ietf.org/html/rfc6455#section-7.1.1
  35. */
  36. enum class role_type
  37. {
  38. /// The stream is operating as a client.
  39. client,
  40. /// The stream is operating as a server.
  41. server
  42. };
  43. } // websocket
  44. } // beast
  45. } // boost
  46. #endif