Class ServiceListener
- java.lang.Object
-
- com.openinventor.inventor.Inventor
-
- com.openinventor.remoteviz.rendering.ServiceListener
-
public class ServiceListener extends Inventor
This class can be overridden by an application to receive notifications from the renderingService
. A typical sequence of calls to this listener is:onConnectedClient
Client
object has been created (isConnected will return true)- onPendingCreateRenderArea
RenderArea
object is about to be created onInstantiatedRenderArea
RenderArea
object has been created (isDisposed will return false)onInitializedClient
Client
is running and bandwidth calibration has finished
Application is running...
onDisposingRenderArea
RenderArea
object will be disposedonDisposedRenderArea
RenderArea
object has been disposed (isDisposed will return true)onDisconnectedClient
Client
object has been disposed (isConnected will return false)
Since RemoteViz 10.6, this class also allows the
Service
to respond to standard HTTP requests using standard HTTP response codes (and messages). This can be useful, for example, to respond to "health check" requests. This method is not suitable to serve high volume requests or HTTP resources, in these cases, prefer a dedicated HTTP server like Apache or Nginx. See onHTTPRequest().Typically the application will attach a listener to the
Service
instance before calling theService
's open() method.For notifications about connections, rendering, input events and client messages see the
RenderAreaListener
class.
-
-
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
-
-
Constructor Summary
Constructors Constructor Description ServiceListener()
Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
onConnectedClient(java.lang.String clientId, NetworkPerformance networkPerformance)
Triggered when a client is connected to the service.void
onDisconnectedClient(java.lang.String clientId)
Triggered when a client is disconnected from the service.void
onDisposedRenderArea(java.lang.String renderAreaId)
Triggered when a renderArea has been disposed.void
onDisposingRenderArea(RenderArea renderArea)
Triggered before a renderArea is disposed.HTTPResponse
onHTTPRequest(HTTPRequest httpRequest)
void
onInitializedClient(Client client, NetworkPerformance networkPerformance)
Triggered when a client is initialized.void
onInstantiatedRenderArea(RenderArea renderArea)
Triggered when a renderArea has been instantiated.void
onMissingLicense(java.lang.String renderAreaId, ConnectionParameters parameters)
Deprecated.As of Open Inventor 10.9.0.0.boolean
onPendingCreateRenderArea(java.lang.String renderAreaId, int[] size, RenderAreaHardware renderAreaHardware, Client client, ConnectionParameters parameters)
Triggered when a connection is pending and the requested renderArea does not exist.\n\n Default behavior : accept the connection by returning true.boolean
onPendingShareRenderArea(RenderArea renderArea, Client client, ConnectionParameters parameters)
Triggered when a connection is pending and the requested renderArea exists.java.lang.String
onRequestedPrivateKeyPassphrase()
Triggered when the secure connection is enabled.-
Methods inherited from class com.openinventor.inventor.Inventor
dispose, getNativeResourceHandle
-
-
-
-
Method Detail
-
onPendingCreateRenderArea
public boolean onPendingCreateRenderArea(java.lang.String renderAreaId, int[] size, RenderAreaHardware renderAreaHardware, Client client, ConnectionParameters parameters)
Triggered when a connection is pending and the requested renderArea does not exist.\n\n Default behavior : accept the connection by returning true.- Parameters:
renderAreaId
- ID identifying the renderArea requested by the clientsize
- client requested width (size[0]
) and height (size[1]
) if the connection parameters contain this information, otherwise it's the renderArea default size. This value can be modified, it determines the created RenderArea size.client
- client that is being connected to the service. If the client does not exist yet, the pointer value will be NULL.parameters
- field-value pairs included in the url during the client connection. See connectTo function in RemoteVizRenderArea.- Returns:
- true if the connection is accepted. The renderArea will be created.
Otherwise returns false. In this case, the client will be notified by an REFUSED disconnect message.
If there are many listeners, the logical operator OR will be applied on all the returned value of listeners.\n
If there are no listeners to call, the connection will be accepted.\n
IMPORTANT : This callback must not contain any calls to the OpenInventor library.
-
onHTTPRequest
public HTTPResponse onHTTPRequest(HTTPRequest httpRequest)
-
onInitializedClient
public void onInitializedClient(Client client, NetworkPerformance networkPerformance)
Triggered when a client is initialized. Default behavior : If network performance calibration is enabledNetworkPerformance.enableCalibration
), the client bandwidth value (ClientSettings.setBandwidth
) is set to the measured network bandwidth value (NetworkPerformance.getBandwidth
).If calibration is enabled, the network performance measures can be retrieved using the networkPerformance parameter (see
NetworkPerformance.getBandwidth
andNetworkPerformance.getLatency
).The client bandwidth value (
ClientSettings.setBandwidth
) influences the quality and the number of interactive frames sent to the client (seeConnectionSettings.setFrameEncodingPolicy
). The higher the value, the better the quality and the number of interactive frames.- Parameters:
client
- : client that is being connected to the service.networkPerformance
- : network performance for the client.
-
onDisconnectedClient
public void onDisconnectedClient(java.lang.String clientId)
Triggered when a client is disconnected from the service.
Default behavior : do nothing- Parameters:
clientId
- : ID identifying the client
-
onDisposingRenderArea
public void onDisposingRenderArea(RenderArea renderArea)
Triggered before a renderArea is disposed. SeeRenderArea.closeConnectionsAndDispose
. After disposing the renderArea, the object will be considered as "disposed" (seeRenderArea.isDisposed
) and will never be reused by RemoteViz internally. This listener is called before onDisposedRenderArea.
Default behavior : do nothing- Parameters:
renderArea
- : the renderArea that will be disposed
-
onConnectedClient
public void onConnectedClient(java.lang.String clientId, NetworkPerformance networkPerformance)
Triggered when a client is connected to the service.
Default behavior : do nothingIf network performance calibration is enabled, the network bandwidth is measured after this call and before calling
onInitializedClient
. Therefore theNetworkPerformance
queries getBandwidth and getLatency will return zero at this point. Use the queries in onInitializedClient to get the measured values.Calibration is enabled by default. Calibration can be disabled using the networkPerformance parameter (see
NetworkPerformance.enableCalibration
). The duration of the calibration measurement (default 5 seconds) can also be modified (seeNetworkPerformance.setMaxCalibrationDuration
).- Parameters:
clientId
- : ID identifying the clientnetworkPerformance
- : network performance for the client.
-
onDisposedRenderArea
public void onDisposedRenderArea(java.lang.String renderAreaId)
Triggered when a renderArea has been disposed. SeeRenderArea.closeConnectionsAndDispose
. At this point, the resources of the renderArea have been released. This listener is called after onDisposingRenderArea.
Default behavior : do nothing- Parameters:
renderAreaId
- : ID identifying the disposed renderArea
-
onRequestedPrivateKeyPassphrase
public java.lang.String onRequestedPrivateKeyPassphrase()
Triggered when the secure connection is enabled. This callback has to return the private key passphrase.If the private key does not contain a passphrase, do not implement this callback. The default implementation will return an empty string.
Security warning !! DO NOT hard-code the passphrase into this callback !!
Read it from a SECURE location on your system.
- See Also:
ServiceSettings.enableSecureConnection Default behavior : returns an empty string.
-
onPendingShareRenderArea
public boolean onPendingShareRenderArea(RenderArea renderArea, Client client, ConnectionParameters parameters)
Triggered when a connection is pending and the requested renderArea exists.
Default behavior : accept the connection by returning true.- Parameters:
renderArea
- : the requested renderAreaclient
- : client that is being connected to the service. If the client does not exist yet, this parameter will be null.parameters
- : field-value pairs included in the url during the client connection. See connectTo function in RemoteVizRenderArea.- Returns:
- true if the connection is accepted, otherwise returns false. In this case, the client will be notified by an REFUSED disconnect message.
If there are many listeners, the logical operator OR will be applied on all the returned value of listeners.
If there are no listeners to call, the connection will be accepted.
-
onMissingLicense
@Deprecated(since="10.9.0.0") public void onMissingLicense(java.lang.String renderAreaId, ConnectionParameters parameters)
Deprecated.As of Open Inventor 10.9.0.0. This listener is not triggered anymore because connections do not require RemoteViz licenses from Open Inventor 10.9This listener is deprecated from Open Inventor 10.9 and is not triggered by RemoteViz anymore. Triggered when a new connection is requested and a RemoteViz license is not found. In this callback, if you release one RemoteViz license (for instance, closing another connection), the new connection will then be opened. Otherwise, a LICENSE disconnect message will be sent to the client (which can choose to notify the user).IMPORTANT: This callback is executed in a separate thread.
RemoteViz is protected by a license key mechanism limiting its use to specified computers or network environments based on commercial agreements. RemoteViz uses floating licenses managed by a license server or an encrypted "master password" string (see SoLockManager).
Default behavior : Post an error message.
Warning Deprecated since Open Inventor 10900. This listener is not triggered anymore because connections do not require RemoteViz licenses from Open Inventor 10.9
-
onInstantiatedRenderArea
public void onInstantiatedRenderArea(RenderArea renderArea)
Triggered when a renderArea has been instantiated.
Default behavior : do nothing- Parameters:
renderArea
- : the instantiated renderArea
-
-