Class used for web socket operations.
More...
#include <NET_WebSocket.h>
|
static bool | readAll (NET_WebStream *stream, UT_WorkBuffer &msg, FrameType &type) |
| Read an entire message in. Really only useful for testing purposes. More...
|
|
static bool | write (NET_WebStream *stream, FrameType type, const UT_StringRef &message, Mask mask=0, exint max_frame_size=-1) |
| Write a websocket message to the stream. More...
|
|
static bool | makeFrame (UT_WorkBuffer &frame, FrameType, const UT_StringView mview, Mask mask=0, bool is_finished=true) |
| Package a frame which is suitable for sending through a web stream. More...
|
|
static bool | makeMessage (UT_WorkBuffer &full_message, FrameType type, const UT_StringRef &message, Mask mask, exint max_fram_size) |
|
template<typename SocketT = NET_WebSocket, typename... Args> |
static UT_SharedPtr< SocketT > | connect (const UT_Url &url, const std::chrono::milliseconds &timeout, Args &&...args) |
|
static constexpr UT_StringLit | frameTypeToString (FrameType type) |
| Convert the frame type to string representation of this frame type. More...
|
|
|
bool | internalSend (FrameType type, const UT_StringRef &message, exint max_frame_size) |
| Create the entire message and place it on the queue to send. More...
|
|
void | flush_ () |
| Flush the currently queue messages to send over the network. More...
|
|
Event | read_ (const std::chrono::milliseconds &timeout=std::chrono::milliseconds(500)) |
| Read a single frame from the server. If you need to read the entire message then loop until this function returns false or is_finished is true. This function will call the callbacks when a full message is received. More...
|
|
Class used for web socket operations.
Definition at line 47 of file NET_WebSocket.h.
All possible error codes that could occur to be sent to the onError callback.
Definition at line 142 of file NET_WebSocket.h.
The currently supported different frame types.
Enumerator |
---|
Continue |
|
Utf8 |
|
Binary |
|
Terminate |
|
Ping |
|
Pong |
|
Definition at line 64 of file NET_WebSocket.h.
NET_WebSocket::NET_WebSocket |
( |
| ) |
|
virtual NET_WebSocket::~NET_WebSocket |
( |
| ) |
|
|
virtualdefault |
exint NET_WebSocket::bufferedAmount |
( |
| ) |
const |
|
inline |
The current amount of bytes waiting to be sent over the network.
- Returns
- The number of bytes waiting to be sent.
Definition at line 312 of file NET_WebSocket.h.
template<typename SocketT = NET_WebSocket, typename... Args>
virtual bool NET_WebSocket::disconnect |
( |
| ) |
|
|
virtual |
void NET_WebSocket::flush_ |
( |
| ) |
|
|
protected |
Flush the currently queue messages to send over the network.
Convert the frame type to string representation of this frame type.
- Parameters
-
type | The frame type to convert. |
- Returns
- The string representation of the frame type.
Definition at line 222 of file NET_WebSocket.h.
int NET_WebSocket::getFD |
( |
| ) |
const |
|
inline |
The file descriptor of this websocket.
- Returns
- The file descriptor
Definition at line 253 of file NET_WebSocket.h.
bool NET_WebSocket::hasData |
( |
| ) |
|
Create the entire message and place it on the queue to send.
- Parameters
-
type | The type of message. |
message | The message to include. |
mask | The mask for the message. |
max_frame_size | The max frame size for the message. |
- Returns
- True if creating the message and buffering did not fail.
bool NET_WebSocket::isConnected |
( |
| ) |
const |
|
inline |
Tell if this websocket is currently in use.
- Returns
- True if this websocket is still in use.
Definition at line 297 of file NET_WebSocket.h.
Package a frame which is suitable for sending through a web stream.
Package up the message into the full message suitable for sending on the socket.
uint32 NET_WebSocket::maxFrameSize |
( |
| ) |
const |
|
inline |
The current max frame size used.
- Returns
- The max frame size
Definition at line 303 of file NET_WebSocket.h.
Event NET_WebSocket::read_ |
( |
const std::chrono::milliseconds & |
timeout = std::chrono::milliseconds(500) | ) |
|
|
protected |
Read a single frame from the server. If you need to read the entire message then loop until this function returns false or is_finished is true. This function will call the callbacks when a full message is received.
- Returns
- True if the read frame was a success.
Read an entire message in. Really only useful for testing purposes.
bool NET_WebSocket::reconnect |
( |
const UT_Url & |
url, |
|
|
const std::chrono::milliseconds & |
timeout |
|
) |
| |
Send a message to the other end of the websocket. This function will send the data immediately and does NOT queue the data. This is a blocking function.
- Parameters
-
Definition at line 270 of file NET_WebSocket.h.
Send a ping to the server. Regular use does not need to worry about this. Other abstractions will do this for you.
Definition at line 281 of file NET_WebSocket.h.
static bool NET_WebSocket::setFrameType |
( |
FrameType & |
type, |
|
|
OpCode |
op_code |
|
) |
| |
|
inlinestaticprotected |
void NET_WebSocket::setMaxFrameSize |
( |
uint32 |
size | ) |
|
|
inline |
Set the max number of bytes sent in each frame.
- Parameters
-
size | The new max frame size |
Definition at line 307 of file NET_WebSocket.h.
The url this websocket is using.
- Returns
- The url object representing the used url.
Definition at line 263 of file NET_WebSocket.h.
bool NET_WebSocket::usableStream |
( |
| ) |
const |
|
inline |
Write a websocket message to the stream.
bool NET_WebSocket::myIsWaitingForPong |
|
protected |
uint32 NET_WebSocket::myMaxFrameSize |
|
protected |
UT_Lock NET_WebSocket::myMessageLock |
|
mutableprotected |
Buffer NET_WebSocket::myReadBuffer |
|
protected |
State NET_WebSocket::myState |
|
protected |
uint64 NET_WebSocket::theMax16FrameSize |
|
static |
The documentation for this class was generated from the following file: