Open Inventor Release 2024.2.0
 
Loading...
Searching...
No Matches
RemoteViz::Rendering::Client Class Reference

RemoteViz More...

#include <RemoteViz/Rendering/Client.h>

Public Member Functions

bool isConnected () const
 Gets the state of the Client: connected or disconnected.
 
const std::string & getId () const
 Gets the id of the client.
 
std::shared_ptr< ConnectiongetConnection (const std::string &id) const
 Gets a Connection of the client.
 
std::shared_ptr< ConnectiongetConnection (unsigned int index) const
 Gets a Connection of the client.
 
unsigned int getNumConnections () const
 Gets the number of client connections.
 
const std::string & getApplicationName () const
 HTML5 client: Returns the domain name of the web host to which the client is connected.
 
const std::string & getEnvironment () const
 HTML5 client: Returns the value of the user-agent header sent by the client web browser.
 
bool isImageStreamingSupported () const
 Returns if the client supports image streaming.
 
bool isVideoStreamingSupported () const
 Returns if the client supports video streaming.
 
bool sendMessage (const std::string &message, std::vector< std::shared_ptr< Connection > > excludedConnections={}) const
 Sends a text message to all the connections of the client.
 
bool sendMessage (const std::vector< unsigned char > &buffer, std::vector< std::shared_ptr< Connection > > excludedConnections={}) const
 Sends a binary message to all the connections of the client.
 
void disconnect ()
 Disconnects the client.
 
std::shared_ptr< ClientSettingsgetSettings () const
 Gets the client settings.
 

Detailed Description

RemoteViz

Represents a client application instance using RemoteViz.

In the case of HTML5 applications, a client represents a web page. See RemoteVizRenderArea.

In the case of the SoRemoteVizClient node, a client represents a single instance of the application using the node.

When a client first connects to the RemoteViz service (e.g by calling the RemoteVizRenderArea method connectTo()), a Client object is automatically created and the ServiceListener method onConnectedClient() is called with the client id. The client object can be queried using Service::getClient(). A Connection object is also created. A RenderArea object is created if the requested render area does not already exist. In any case the Connection can be queried using the getConnection() method and the associated RenderArea can be queried using the Connection::getRenderArea() method.

A service has zero clients initially and may allow one client or multiple clients (see ServiceListener methods onPendingCreateRenderArea and onPendingShareRenderArea). While the service is running, you can get the current client(s) using the Service methods getNumClients() and getClient().

A client has at least one connection but may have multiple connections if the service allows that. See the methods getNumConnections() and getConnection().

When a client is disconnected, the ServiceListener method onDisconnectedClient() is called. Following this call, the client object will no longer be referenced by RemoteViz and will be disposed unless the application holds a reference.

Definition at line 78 of file Client.h.

Member Function Documentation

◆ disconnect()

void RemoteViz::Rendering::Client::disconnect ( )

Disconnects the client.

A KICKED disconnect message will be sent to all connections of the client, then they will be disconnected.

◆ getApplicationName()

const std::string & RemoteViz::Rendering::Client::getApplicationName ( ) const

HTML5 client: Returns the domain name of the web host to which the client is connected.


Specifically, RemoteVizClient.js uses the JavaScript command “window.location.host”. Note that this command returns an empty string when the URL is a file path (starting with “file://”). In this case, there is no domain name.

SoRemoteVizClient node: Returns the string "SoRemoteVizClient".

Returns
the application name.

◆ getConnection() [1/2]

std::shared_ptr< Connection > RemoteViz::Rendering::Client::getConnection ( const std::string &  id) const

Gets a Connection of the client.

Parameters
id: ID identifying the connection.
Returns
the connection object if the id exists, otherwise returns null.

◆ getConnection() [2/2]

std::shared_ptr< Connection > RemoteViz::Rendering::Client::getConnection ( unsigned int  index) const

Gets a Connection of the client.

See getNumConnections().

Parameters
index: index identifying the client
Returns
the connection object if the index exists, otherwise returns null.

◆ getEnvironment()

const std::string & RemoteViz::Rendering::Client::getEnvironment ( ) const

HTML5 client: Returns the value of the user-agent header sent by the client web browser.

SoRemoteVizClient node: Returns the operating system (OS) running the client application.

Returns
the environment.

◆ getId()

const std::string & RemoteViz::Rendering::Client::getId ( ) const

Gets the id of the client.

The client id is a Globally Unique Identifier (GUID) created by RemoteViz.

Returns
the ID identifying the client

◆ getNumConnections()

unsigned int RemoteViz::Rendering::Client::getNumConnections ( ) const

Gets the number of client connections.

Returns
the number of connections

◆ getSettings()

std::shared_ptr< ClientSettings > RemoteViz::Rendering::Client::getSettings ( ) const

Gets the client settings.

Returns
the client settings object

◆ isConnected()

bool RemoteViz::Rendering::Client::isConnected ( ) const

Gets the state of the Client: connected or disconnected.

Connected (true) means the Client has at least one active Connection. When a Client is being disconnected, the ServiceListener method onDisconnectedClient() is called. Just before this call, the Client state is set to "disconnected". Following this call, the Client object will no longer be referenced by RemoteViz and will be disposed unless the application holds a reference. RemoteViz will never reuse the object internally.

Returns
true if the client is connected or false if the client is disconnected.

◆ isImageStreamingSupported()

bool RemoteViz::Rendering::Client::isImageStreamingSupported ( ) const

Returns if the client supports image streaming.

Returns
true if image streaming is supported.

◆ isVideoStreamingSupported()

bool RemoteViz::Rendering::Client::isVideoStreamingSupported ( ) const

Returns if the client supports video streaming.

Returns
true if video streaming is supported.

◆ sendMessage() [1/2]

bool RemoteViz::Rendering::Client::sendMessage ( const std::string &  message,
std::vector< std::shared_ptr< Connection > >  excludedConnections = {} 
) const

Sends a text message to all the connections of the client.

Parameters
message: the message to be sent to all the connections of the client
excludedConnections: optional - the connections that should not receive the message.
Returns
true if the message has been successfully sent to all connections, otherwise returns false.

◆ sendMessage() [2/2]

bool RemoteViz::Rendering::Client::sendMessage ( const std::vector< unsigned char > &  buffer,
std::vector< std::shared_ptr< Connection > >  excludedConnections = {} 
) const

Sends a binary message to all the connections of the client.

Parameters
buffer: the binary buffer to be sent to all connections of the client
excludedConnections: optional - the connections that should not receive the message.
Returns
true if the message has been successfully sent to all connections, otherwise returns false.

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