...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
Provides message-oriented functionality using WebSocket.
Defined in header <boost/beast/websocket/stream.hpp>
template< class NextLayer, bool deflateSupported> class stream
Name |
Description |
---|---|
The type of the executor associated with the object. |
|
Indicates if the permessage-deflate extension is supported. |
|
The type of the next layer. |
Name |
Description |
---|---|
Perform the WebSocket handshake in the server role. Read and respond to a WebSocket HTTP Upgrade request. Respond to a WebSocket HTTP Upgrade request. |
|
Perform the WebSocket handshake asynchronously in the server role. |
|
Send a websocket close control frame asynchronously. |
|
Perform the WebSocket handshake asynchronously in the client role. |
|
Send a websocket ping control frame asynchronously. |
|
Send a websocket pong control frame asynchronously. |
|
Read a complete message asynchronously. |
|
Read some message data asynchronously. |
|
Write a complete message asynchronously. |
|
Write some message data asynchronously. |
|
Set the automatic fragmentation option. Returns true if the automatic fragmentation option is set. |
|
Set the binary message write option. Returns true if the binary message write option is set. |
|
Send a websocket close control frame. |
|
Set a callback to be invoked on each incoming control frame. Reset the control frame callback. |
|
Get the executor associated with the object. |
|
Get the permessage-deflate extension options. |
|
Returns true if the latest message data indicates binary. |
|
Returns true if the latest message data indicates text. |
|
Perform the WebSocket handshake in the client role. |
|
Returns true if the last completed read finished the current message. |
|
Returns true if the stream is open. |
|
Get a reference to the next layer. |
|
Move assignment (deleted) |
|
Send a websocket ping control frame. |
|
Send a websocket pong control frame. |
|
Read a complete message. |
|
Set the maximum incoming message size option. Returns the maximum incoming message size setting. |
|
Returns a suggested maximum buffer size for the next call to read. |
|
Read some message data. |
|
Returns the close reason received from the remote peer. |
|
Set whether the PRNG is cryptographically secure. |
|
Set the permessage-deflate extension options. |
|
Constructor. |
|
Set the text message write option. Returns true if the text message write option is set. |
|
Write a complete message. |
|
Set the write buffer size option. Returns the size of the write buffer. |
|
Write some message data. |
|
Destructor. |
The websocket::stream
class template provides asynchronous
and blocking message-oriented functionality necessary for clients and servers
to utilize the WebSocket protocol. For asynchronous operations, the application
must ensure that they are are all performed within the same implicit or explicit
strand.
Distinct objects: Safe.
Shared objects: Unsafe. The application must also ensure that all asynchronous operations are performed within the same implicit or explicit strand.
To declare the websocket::stream
object with a tcp_stream
in a multi-threaded asynchronous
program using a strand, you may write:
websocket::stream<tcp_stream> ws{net::io_context::strand(ioc)};
Alternatively, for a single-threaded or synchronous application you may write:
websocket::stream<tcp_stream> ws(ioc);
Type |
Description |
---|---|
|
The type representing the next layer, to which data will be read and written during operations. For synchronous operations, the type must support the SyncStream concept. For asynchronous operations, the type must support the AsyncStream concept. |
|
A |
A stream object must not be moved or destroyed while there are pending asynchronous operations associated with it.
Convenience header <boost/beast/websocket.hpp>