|
CoreComponents 4.0.0
A Modern C++ Toolkit
|
WebSocket message stream. More...
#include <cc/WebSocketStream>
Public Types | |
| enum | Type { ServerToClient = 0 , ClientToServer = 1 } |
| Communication direction. More... | |
Public Types inherited from Object | |
| using | NullAccess = cc::NullAccess |
| Error thrown when trying to access a null object. | |
| using | VirginityTestFailed = cc::VirginityTestFailed |
| Error thrown when trying to initialize an object with a non-virgin state. | |
Public Member Functions | |
| WebSocketStream ()=default | |
| Create a null object. | |
| WebSocketStream (const Stream &stream, Type type) | |
| Create a new frame stream. | |
| WebSocketStream & | maxOutgoingFramePayloadSize (long size) |
| Set the maximum frame payload size | |
| WebSocketStream & | maxIncomingMessageSize (long size) |
| Set a limit for the maximum incoming message size | |
| WebSocketStream & | onPingReceived (Function< void()> &&f) |
| Set a callback handler f to be invoked whenever a ping frame is received | |
| WebSocketStream & | onPongReceived (Function< void()> &&f) |
| Set a callback handler f to be invoked whenever a pong frame is received | |
| bool | read (Out< String > message, Out< WebSocketMessage::Type > type=None{}) |
| Receive a message. | |
| bool | write (const String &message, WebSocketMessage::Type type=WebSocketMessage::Type::Text, uint32_t mask=0) |
| Send a message. | |
| bool | write (const Bytes &message, WebSocketMessage::Type type=WebSocketMessage::Type::Binary, uint32_t mask=0) |
| Send a message. | |
| bool | isOpen () const |
| Tell if this WebSocket connection is still open. | |
| bool | close (WebSocketStatus status) |
| Close this WebSocket connection. | |
| WebSocketStatus | status () const |
| Status of this WebSocket connection | |
| bool | ping () |
| Send a ping frame. | |
| bool | pong () |
| Send an unsolicited pong frame. | |
Public Member Functions inherited from Object | |
| Object ()=default | |
| Create a null object. | |
| operator bool () const | |
| Check if this is a non-null object. | |
| bool | isNull () const |
| Check if this is a null object. | |
| int | useCount () const |
| Reference count. | |
| template<class T > | |
| bool | is () const |
| Check if this object is of type T. | |
| template<class T > | |
| T | as () const |
| Cast this object to type T. | |
| bool | isWeak () const |
| Check if the underlying object reference is weak. | |
| bool | operator== (const Object &other) const |
| Equality operator. | |
| std::strong_ordering | operator<=> (const Object &other) const |
| Ordering operator. | |
Additional Inherited Members | |
Protected Member Functions inherited from Object | |
| template<class T > | |
| T | weak () const |
| template<class T > | |
| void | initOnce () |
| Create the object state when called the first time. | |
| template<class T > | |
| void | initOncePerThread () |
| Create a distinct object state for each thread when called the first time in that thread. | |
| Object (State *newState) | |
| Initialize object with newState. | |
| Object (State *state, Alias) | |
| Object (State *state, Weak) | |
| Object & | operator= (std::nullptr_t) |
Static Protected Member Functions inherited from Object | |
| template<class T > | |
| static T | alias (const State *state) |
| Create an alias object for the given state. | |
| template<class T > | |
| static T | weak (const State *state) |
Protected Attributes inherited from Object | |
| Handle< State > | me |
| Internal object state | |
WebSocket message stream.
add a waitUntil();
add configuration option and logic for websocket keep alive interval (two misses result in connection termination)
make sure WebSocket connections are brought down cleanly on server shutdown
| enum Type |
|
default |
Create a null object.
|
explicit |
Create a new frame stream.
| WebSocketStream & maxOutgoingFramePayloadSize | ( | long | size | ) |
Set the maximum frame payload size
| WebSocketStream & maxIncomingMessageSize | ( | long | size | ) |
Set a limit for the maximum incoming message size
| WebSocketStream & onPingReceived | ( | Function< void()> && | f | ) |
Set a callback handler f to be invoked whenever a ping frame is received
| WebSocketStream & onPongReceived | ( | Function< void()> && | f | ) |
Set a callback handler f to be invoked whenever a pong frame is received
| bool read | ( | Out< String > | message, |
| Out< WebSocketMessage::Type > | type = None{} |
||
| ) |
Receive a message.
| bool write | ( | const String & | message, |
| WebSocketMessage::Type | type = WebSocketMessage::Type::Text, |
||
| uint32_t | mask = 0 |
||
| ) |
Send a message.
| bool write | ( | const Bytes & | message, |
| WebSocketMessage::Type | type = WebSocketMessage::Type::Binary, |
||
| uint32_t | mask = 0 |
||
| ) |
Send a message.
| bool isOpen | ( | ) | const |
Tell if this WebSocket connection is still open.
| bool close | ( | WebSocketStatus | status | ) |
Close this WebSocket connection.
| WebSocketStatus status | ( | ) | const |
Status of this WebSocket connection
| bool ping | ( | ) |
Send a ping frame.
| bool pong | ( | ) |
Send an unsolicited pong frame.