Open Inventor Release 2024.1.3
 
Loading...
Searching...
No Matches
RemoteViz::Rendering::Connection Class Reference

RemoteViz More...

#include <RemoteViz/Rendering/Connection.h>

Public Member Functions

bool isOpen () const
 Gets the state of the Connection: open or closed.
 
const std::string & getId () const
 Gets the id of the connection.
 
std::shared_ptr< ConnectionSettingsgetSettings () const
 Gets the connection settings.
 
std::shared_ptr< const ConnectionParametersgetParameters () const
 Gets the connection parameters.
 
std::shared_ptr< RenderAreagetRenderArea () const
 Gets the RenderArea associated with the connection.
 
unsigned int getRequestedWidth () const
 Gets the last renderArea width requested by the client.
 
unsigned int getRequestedHeight () const
 Gets the last renderArea height requested by the client.
 
unsigned int getContainerWidth () const
 Gets the client container width.
 
unsigned int getContainerHeight () const
 Gets the client container height.
 
std::shared_ptr< ClientgetClient () const
 Gets the client associated with this connection.
 
bool sendMessage (const std::string &message) const
 Sends a text message to the client.
 
bool sendMessage (const std::vector< unsigned char > &buffer) const
 Sends a binary message to the client.
 
void close ()
 Closes the connection.
 
EncodedFrame getLastEncodedFrame () const
 Gets the last encoded frame sent by the connection.
 

Detailed Description

RemoteViz

Represents a connection from a Client to a RenderArea managed by the RemoteViz service.

A Connection object is created automatically by RemoteViz when a client connects to the service. Each connection belongs to a single Client and a single RenderArea. Each Client may have multiple connections, for example when multiple render areas are created on the same browser page. Each RenderArea may have multiple connections if it is shared, i.e. displayed in multiple client render areas. Use the Service object to query a client, then use the Client object to query its connections.

A Connection object is passed to many of the RenderAreaListener methods including onOpenedConnection(), onInitializedConnection() and onSendingFrame().

Using a Connection object, the application can query the current width and height of the client "container" in pixels and the last RenderArea width and height requested by the client. Note that the render area and the container are not required to be the same size. If the aspect ratios are different, then the rendered image will be displayed inside the container according to the "displayMode" specified when the client called the RemoteVizRenderArea constructor or set the 'displayMode' field of the SoRemoteVizClient node. Possible values are FIT (default), CROP and STRETCH.

A Connection allows the application to send text or binary messages to the associated client. A JavaScript client will receive the message using a listener (see the RemoteVizRenderArea method addServiceListener). Messages from a client are received using one of the RenderAreaListener::onReceivedMessage() methods.

Definition at line 81 of file Connection.h.

Member Function Documentation

◆ close()

void RemoteViz::Rendering::Connection::close ( )

Closes the connection.

A KICKED disconnect message will be sent to the client.

◆ getClient()

std::shared_ptr< Client > RemoteViz::Rendering::Connection::getClient ( ) const

Gets the client associated with this connection.

Returns
the ID identifying the client

◆ getContainerHeight()

unsigned int RemoteViz::Rendering::Connection::getContainerHeight ( ) const

Gets the client container height.

Returns
the client container height

◆ getContainerWidth()

unsigned int RemoteViz::Rendering::Connection::getContainerWidth ( ) const

Gets the client container width.

Returns
the client container width

◆ getId()

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

Gets the id of the connection.

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

Returns
the ID identifying the connection

◆ getLastEncodedFrame()

EncodedFrame RemoteViz::Rendering::Connection::getLastEncodedFrame ( ) const

Gets the last encoded frame sent by the connection.

Returns
encoded frame.

◆ getParameters()

std::shared_ptr< const ConnectionParameters > RemoteViz::Rendering::Connection::getParameters ( ) const

Gets the connection parameters.

These are field-value pairs included in the url during the client connection. See RemoteVizRenderArea::connectTo().

Returns
the connection parameters object

◆ getRenderArea()

std::shared_ptr< RenderArea > RemoteViz::Rendering::Connection::getRenderArea ( ) const

Gets the RenderArea associated with the connection.

Returns
the renderArea object

◆ getRequestedHeight()

unsigned int RemoteViz::Rendering::Connection::getRequestedHeight ( ) const

Gets the last renderArea height requested by the client.

Returns
the requested renderArea height

◆ getRequestedWidth()

unsigned int RemoteViz::Rendering::Connection::getRequestedWidth ( ) const

Gets the last renderArea width requested by the client.

Returns
the requested renderArea width

◆ getSettings()

std::shared_ptr< ConnectionSettings > RemoteViz::Rendering::Connection::getSettings ( ) const

Gets the connection settings.

Returns
the connection settings object

◆ isOpen()

bool RemoteViz::Rendering::Connection::isOpen ( ) const

Gets the state of the Connection: open or closed.

RemoteViz does not keep a reference to the Connection object after the connection is closed. If the application kept a reference to the object, this method can be used to query its state. If the application did not keep a reference, then the Connection object will be disposed after the connection is closed.

Note: RemoteViz objects are not reference counted like Open Inventor nodes, but std::shared_ptr provides a similar mechanism.

The state "closed" will be set just before triggering the listener RenderAreaListener::onClosedConnection.

Returns
true if the connection is open or false if the connection is closed.

◆ sendMessage() [1/2]

bool RemoteViz::Rendering::Connection::sendMessage ( const std::string &  message) const

Sends a text message to the client.

The client-side message event will be triggered.

Parameters
message: the message to be sent to the client
Returns
true if the message has been successfully sent, otherwise returns false.

◆ sendMessage() [2/2]

bool RemoteViz::Rendering::Connection::sendMessage ( const std::vector< unsigned char > &  buffer) const

Sends a binary message to the client.

The client-side message event will be triggered.

Parameters
buffer: the binary message to be sent to the client
Returns
true if the message has been successfully sent, otherwise returns false.

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