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 rendering Service. A typical sequence of calls to this listener is:

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 the Service's open() method.

For notifications about connections, rendering, input events and client messages see the RenderAreaListener class.

  • Constructor Details

    • ServiceListener

      public ServiceListener()
      Default constructor.
  • Method Details

    • onPendingCreateRenderArea

      public boolean onPendingCreateRenderArea(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 client
      size - 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 enabled NetworkPerformance.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 and NetworkPerformance.getLatency).

      The client bandwidth value (ClientSettings.setBandwidth) influences the quality and the number of interactive frames sent to the client (see ConnectionSettings.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(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. See RenderArea.closeConnectionsAndDispose. After disposing the renderArea, the object will be considered as "disposed" (see RenderArea.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(String clientId, NetworkPerformance networkPerformance)
      Triggered when a client is connected to the service.

      Default behavior : do nothing

      If network performance calibration is enabled, the network bandwidth is measured after this call and before calling onInitializedClient. Therefore the NetworkPerformance 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 (see NetworkPerformance.setMaxCalibrationDuration).

      Parameters:
      clientId - : ID identifying the client

      networkPerformance - : network performance for the client.
    • onDisposedRenderArea

      public void onDisposedRenderArea(String renderAreaId)
      Triggered when a renderArea has been disposed. See RenderArea.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 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:
    • 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 renderArea

      client - : 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(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.9
      This 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