HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NET_WebSocketSet Class Reference

#include <NET_WebSocketSet.h>

Classes

class  Event
 Describes an event that has occured. More...
 

Public Member Functions

bool connect (const UT_StringRef &id, const UT_Url &url, const std::chrono::milliseconds &timeout)
 Connect to a remote server. More...
 
bool getNextEvent (Event &ev, const std::chrono::milliseconds &timeout)
 Use this function to poll for new events if there are currently no queued events. More...
 
bool disconnect (const UT_StringHolder &id)
 Close a specific connection based on the provided id. A DISCONNECTED or DISCONNECT_ERROR will be generated. More...
 
void disconnectAll ()
 Disconnect all connections this manager currently manages. More...
 
void sendMessage (const UT_StringHolder &id, const UT_StringHolder &message)
 Send a message to a particular connection. This generates a MESSAGE_SENT or MESSAGE_SEND_ERROR. More...
 

Friends

class NET_WebSocketItem
 

Detailed Description

The WebSocketSet is responsible for creating and managing one or more client-side web socket connections.

The methods for sending data assume a "fire and forget" approach, with no connection to data coming back through the sockets. As such, these methods should be strictly non-blocking.

Definition at line 36 of file NET_WebSocketSet.h.

Member Function Documentation

bool NET_WebSocketSet::connect ( const UT_StringRef id,
const UT_Url url,
const std::chrono::milliseconds &  timeout 
)

Connect to a remote server.

Parameters
idThe id of the connected websocket.
urlThe url of the websocket.
timeoutThe timeout to use before giving up on connecting.
Returns
True if a connected websocket was produced.
bool NET_WebSocketSet::disconnect ( const UT_StringHolder id)

Close a specific connection based on the provided id. A DISCONNECTED or DISCONNECT_ERROR will be generated.

Parameters
idThe id to identify which connection to close.
Returns
True if the connection was disconnected.
void NET_WebSocketSet::disconnectAll ( )

Disconnect all connections this manager currently manages.

bool NET_WebSocketSet::getNextEvent ( Event ev,
const std::chrono::milliseconds &  timeout 
)

Use this function to poll for new events if there are currently no queued events.

Parameters
evThe object describing the event.
timeoutA timeout of 0 means only return an event if there is one
Returns
True if this function is returning an event.
void NET_WebSocketSet::sendMessage ( const UT_StringHolder id,
const UT_StringHolder message 
)

Send a message to a particular connection. This generates a MESSAGE_SENT or MESSAGE_SEND_ERROR.

Parameters
idThe id of the connection to send the message too.
wbufThe message to send.

Friends And Related Function Documentation

friend class NET_WebSocketItem
friend

Definition at line 38 of file NET_WebSocketSet.h.


The documentation for this class was generated from the following file: