NDEVR
API Documentation
SocketIO

Provides the ability to communicate over a network using SocketIO (https://socket.io/docs/v4/). More...

Public Member Functions

 ~SocketIO ()
 Destructor.
void addChannel (DynamicPointer< SocketIOChannel > &channel)
 Adds an existing channel to this connection.
void close ()
 Closes the current connection.
bool connect (const StringView &url="http://ndevr.org:3000")
 Connects to a SocketIO server at the given URL.
DynamicPointer< SocketIOChannelcreateChannel (const StringView &name, std::function< void(const char *data, uint04 size)> data_callback, UUID target=Constant< UUID >::Invalid)
 Creates a new communication channel with a data receive callback.
DynamicPointer< SocketIOChannelcreateChannel (const StringView &name, UUID target=Constant< UUID >::Invalid)
 Creates a new communication channel with the given name.
bool isConnected () const
 Checks whether the client is currently connected.
const Dictionary< UUID, String > & onlineClients () const
 Gets the dictionary of currently online clients.
void removeChannel (DynamicPointer< SocketIOChannel > &channel)
 Removes a channel from this connection.
void setName (const StringView &name)
 Sets the display name for this client.
void setRunID (const UUID &run_id)
 Sets the run ID for this session.
const Stringurl () const
 Gets the current server URL.

Static Public Member Functions

static DynamicPointer< SocketIOGetSocketIO (const StringView &url="http://ndevr.org:3000")
 Gets or creates a shared SocketIO instance for the given URL.

Protected Member Functions

 SocketIO (QObject *parent=0)
 Constructs a SocketIO instance.

Detailed Description

Provides the ability to communicate over a network using SocketIO (https://socket.io/docs/v4/).


Definition at line 50 of file SocketIO.h.

Constructor & Destructor Documentation

◆ SocketIO()

SocketIO::SocketIO ( QObject * parent = 0)
explicitprotected

Constructs a SocketIO instance.

Parameters
[in]parentThe parent QObject.

◆ ~SocketIO()

SocketIO::~SocketIO ( )

Destructor.

Cleans up the SocketIO connection.

Member Function Documentation

◆ addChannel()

void SocketIO::addChannel ( DynamicPointer< SocketIOChannel > & channel)

Adds an existing channel to this connection.

Parameters
[in]channelThe channel to add.

◆ connect()

bool SocketIO::connect ( const StringView & url = "http://ndevr.org:3000")

Connects to a SocketIO server at the given URL.

Parameters
[in]urlThe server URL to connect to.
Returns
True if the connection was successful.

References url().

◆ createChannel() [1/2]

DynamicPointer< SocketIOChannel > SocketIO::createChannel ( const StringView & name,
std::function< void(const char *data, uint04 size)> data_callback,
UUID target = ConstantUUID >::Invalid )

Creates a new communication channel with a data receive callback.

Parameters
[in]nameThe channel name.
[in]data_callbackCallback invoked when data is received on this channel.
[in]targetThe UUID of the target client, or invalid for broadcast.
Returns
A shared pointer to the created SocketIOChannel.

◆ createChannel() [2/2]

DynamicPointer< SocketIOChannel > SocketIO::createChannel ( const StringView & name,
UUID target = ConstantUUID >::Invalid )

Creates a new communication channel with the given name.

Parameters
[in]nameThe channel name.
[in]targetThe UUID of the target client, or invalid for broadcast.
Returns
A shared pointer to the created SocketIOChannel.

◆ GetSocketIO()

DynamicPointer< SocketIO > SocketIO::GetSocketIO ( const StringView & url = "http://ndevr.org:3000")
static

Gets or creates a shared SocketIO instance for the given URL.

Parameters
[in]urlThe server URL to connect to.
Returns
A shared pointer to the SocketIO instance.

References url().

◆ isConnected()

bool SocketIO::isConnected ( ) const
inline

Checks whether the client is currently connected.

Returns
True if connected to the server.

Definition at line 108 of file SocketIO.h.

◆ onlineClients()

const Dictionary< UUID, String > & SocketIO::onlineClients ( ) const

Gets the dictionary of currently online clients.

Returns
A reference to the dictionary mapping client UUIDs to names.

◆ removeChannel()

void SocketIO::removeChannel ( DynamicPointer< SocketIOChannel > & channel)

Removes a channel from this connection.

Parameters
[in]channelThe channel to remove.

◆ setName()

void SocketIO::setName ( const StringView & name)

Sets the display name for this client.

Parameters
[in]nameThe name to identify this client.

◆ setRunID()

void SocketIO::setRunID ( const UUID & run_id)

Sets the run ID for this session.

Parameters
[in]run_idThe UUID identifying this run.

◆ url()

const String & SocketIO::url ( ) const
inline

Gets the current server URL.

Returns
A reference to the URL string.

Definition at line 112 of file SocketIO.h.

Referenced by connect(), and GetSocketIO().


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