Class 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 Detail

      • ServiceListener

        public ServiceListener()
        Default constructor.
    • 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 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.

      • 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. 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​(java.lang.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​(java.lang.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 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 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
        public void onMissingLicense​(java.lang.String renderAreaId,
                                     ConnectionParameters parameters)
        Deprecated.
        As of Open Inventor 10900. 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