Class Client
- java.lang.Object
-
- com.openinventor.inventor.Inventor
-
- com.openinventor.remoteviz.rendering.Client
-
public class Client extends Inventor
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 theServiceListener
method onConnectedClient() is called with the client id. The client object can be queried usingService.getClient()
. AConnection
object is also created. ARenderArea
object is created if the requested render area does not already exist. In any case theConnection
can be queried using thegetConnection()
method and the associatedRenderArea
can be queried using theConnection.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 theService
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()
andgetConnection()
.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.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.openinventor.inventor.Inventor
Inventor.ConstructorCommand
-
-
Field Summary
-
Fields inherited from class com.openinventor.inventor.Inventor
VERBOSE_LEVEL, ZeroHandle
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
disconnect()
Disconnects the client.java.lang.String
getApplicationName()
HTML5 client: Returns the domain name of the web host to which the client is connected.Connection
getConnection(int index)
Gets aConnection
of the client.Connection
getConnection(java.lang.String id)
Gets aConnection
of the client.java.lang.String
getEnvironment()
HTML5 client: Returns the value of the user-agent header sent by the client web browser.java.lang.String
getId()
Gets the id of the client.int
getNumConnections()
Gets the number of client connections.ClientSettings
getSettings()
Gets the client settings.boolean
isConnected()
Gets the state of theClient
: connected or disconnected.boolean
isImageStreamingSupported()
Returns if the client supports image streaming.boolean
isVideoStreamingSupported()
Returns if the client supports video streaming.boolean
sendMessage(java.lang.String message)
Calls sendMessage(message, new java.util.ArrayList<>()).boolean
sendMessage(java.lang.String message, java.util.Collection<Connection> excludedConnections)
Sends a text message to all the connections of the client.boolean
sendMessage(java.util.Collection<java.lang.Byte> buffer)
Calls sendMessage(buffer, new java.util.ArrayList<>()).boolean
sendMessage(java.util.Collection<java.lang.Byte> buffer, java.util.Collection<Connection> excludedConnections)
Sends a binary message to all the connections of the client.-
Methods inherited from class com.openinventor.inventor.Inventor
dispose, getNativeResourceHandle
-
-
-
-
Method Detail
-
sendMessage
public boolean sendMessage(java.lang.String message)
Calls sendMessage(message, new java.util.ArrayList<>()).
-
sendMessage
public boolean sendMessage(java.util.Collection<java.lang.Byte> buffer)
Calls sendMessage(buffer, new java.util.ArrayList<>()).
-
getConnection
public Connection getConnection(int index)
- Parameters:
index
- : index identifying the client- Returns:
- the connection object if the index exists, otherwise returns null.
-
getConnection
public Connection getConnection(java.lang.String id)
Gets aConnection
of the client.- Parameters:
id
- : ID identifying the connection.- Returns:
- the connection object if the id exists, otherwise returns null.
-
getId
public java.lang.String getId()
Gets the id of the client. The client id is a Globally Unique Identifier (GUID) created by RemoteViz.- Returns:
- the ID identifying the client
-
isVideoStreamingSupported
public boolean isVideoStreamingSupported()
Returns if the client supports video streaming.- Returns:
- true if video streaming is supported.
-
isConnected
public boolean isConnected()
Gets the state of theClient
: connected or disconnected. Connected (true) means theClient
has at least one activeConnection
. When aClient
is being disconnected, theServiceListener
method onDisconnectedClient() is called. Just before this call, theClient
state is set to "disconnected". Following this call, theClient
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.
-
getEnvironment
public java.lang.String getEnvironment()
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.
-
sendMessage
public boolean sendMessage(java.util.Collection<java.lang.Byte> buffer, java.util.Collection<Connection> excludedConnections)
Sends a binary message to all the connections of the client.- Parameters:
buffer
- : the binary buffer to be sent to all connections of the clientexcludedConnections
- : optional - the connections that should not receive the message.- Returns:
- true if the message has been successfully sent to all connections, otherwise returns false.
-
isImageStreamingSupported
public boolean isImageStreamingSupported()
Returns if the client supports image streaming.- Returns:
- true if image streaming is supported.
-
sendMessage
public boolean sendMessage(java.lang.String message, java.util.Collection<Connection> excludedConnections)
Sends a text message to all the connections of the client.- Parameters:
message
- : the message to be sent to all the connections of the clientexcludedConnections
- : optional - the connections that should not receive the message.- Returns:
- true if the message has been successfully sent to all connections, otherwise returns false.
-
getNumConnections
public int getNumConnections()
Gets the number of client connections.- Returns:
- the number of connections
-
getSettings
public ClientSettings getSettings()
Gets the client settings.- Returns:
- the client settings object
-
getApplicationName
public java.lang.String getApplicationName()
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.
-
disconnect
public void disconnect()
Disconnects the client. A KICKED disconnect message will be sent to all connections of the client, then they will be disconnected.
-
-