Class DesktopConnection

java.lang.Object
com.openfin.desktop.DesktopConnection

public class DesktopConnection
extends java.lang.Object
A object for launching, connecting to, and controlling Runtime.
  • Constructor Details

    • DesktopConnection

      public DesktopConnection​(java.lang.String uuid) throws DesktopException

      Creates a new connection to Runtime.

      If the system property "com.openfin.desktop.threads.message.out=nThreads" is defined, it creates OpenFinThreadPool with fixed thread pool size of nThread and uses it to send outgoing messages. If the system property "com.openfin.desktop.threads.message.in=nThreads" is defined, it creates OpenFinThreadPool with fixed thread pool size of nThread and uses it to process incoming messages. Otherwise ForkJoinPool.commonPool() will be used to process incoming and/or outgoing messages.

      Parameters:
      uuid - unique ID for Runtime to refer to this DesktopConnection
      Throws:
      DesktopException - if this method fails to create a connection
    • DesktopConnection

      public DesktopConnection​(java.lang.String uuid, java.lang.String host, java.lang.Integer port) throws DesktopException
      Deprecated.
      Creates a new connection to Runtime.
      Parameters:
      uuid - unique ID for Runtime to refer to this DesktopConnection
      host - The host that Runtime is running on. Only "localhost" is accepted
      port - The port that Runtime is listening on for connections. -null if unknown
      Throws:
      DesktopException - if this method fails to create a connection
  • Method Details

    • connect

      public void connect​(RuntimeConfiguration configuration, DesktopStateListener listener, int timeout) throws DesktopIOException, java.io.IOException
      Connect to Runtime with the specified configuration. If the specified version is not running, this method will try to start it.
      Parameters:
      configuration - an instance of RuntimeConfiguration
      listener - Receives updates on startup and connection state
      timeout - number of seconds to wait for connection. If connection to Runtime is not established by the timeout the listener will get an onError() call
      Throws:
      DesktopIOException - if this method fails to connect to Runtime
      java.io.IOException - if IO exception is thrown during launching Runtime
      See Also:
      RuntimeConfiguration
    • disconnect

      public void disconnect() throws DesktopException
      Disconnects from Runtime
      Throws:
      DesktopException - if this method fails to disconnect from Runtime
    • disconnect

      protected void disconnect​(java.lang.String reason) throws DesktopException
      Throws:
      DesktopException
    • isConnected

      public boolean isConnected()
      InterApplicationBus
      Returns:
      true if connected
    • exit

      public void exit() throws DesktopException
      Notify Runtime to exit
      Throws:
      DesktopException - if this method fails to exit
    • getInterApplicationBus

      public InterApplicationBus getInterApplicationBus()
      Gets the Inter-Application message dispatcher associated with this DesktopConnection
      Returns:
      InterApplicationBus
    • getPort

      public java.lang.Integer getPort()
      Gets port number that Runtime is running on
      Returns:
      port number
    • sendAction

      public void sendAction​(java.lang.String action, org.json.JSONObject payload) throws DesktopException
      Sends a message to Runtime
      Parameters:
      action - The action of the message
      payload - The message object to send
      Throws:
      DesktopException - if this method fails to send the message
    • sendActionAsync

      public java.util.concurrent.CompletableFuture<Ack> sendActionAsync​(java.lang.String action, org.json.JSONObject payload, java.lang.Object source)
    • sendAction

      public void sendAction​(java.lang.String action, org.json.JSONObject payload, AckListener ackListener, java.lang.Object source)
      Sends a message to Runtime
      Parameters:
      action - The action of the message
      payload - The message object to send
      ackListener - AckListener for the message
      source - Message source
      See Also:
      AckListener
    • connect

      public void connect​(DesktopStateListener listener)
      Connects to an Runtime process. Internal use only
      Parameters:
      listener - Receives updates on startup and connection state
      See Also:
      DesktopStateListener
    • addEventCallbackAsync

      public java.util.concurrent.CompletionStage<Ack> addEventCallbackAsync​(org.json.JSONObject subscriptionObject, EventListener listener, java.lang.Object source)
    • addEventCallback

      public void addEventCallback​(org.json.JSONObject subscriptionObject, EventListener listener, AckListener callback, java.lang.Object source)
      Registers an event listener on the specified event
      Parameters:
      subscriptionObject - JSON object containing subscription information such as the topic and type
      listener - EventListener for the event
      callback - AckListener for this request
      source - Source of this request
      See Also:
      EventListener, AckListener
    • removeEventCallbackAsync

      public java.util.concurrent.CompletionStage<Ack> removeEventCallbackAsync​(org.json.JSONObject subscriptionObject, EventListener listener, java.lang.Object source)
    • removeEventCallback

      public void removeEventCallback​(org.json.JSONObject subscriptionObject, EventListener listener, AckListener callback, java.lang.Object source)
      Removes a previously registered event listener from the specified event
      Parameters:
      subscriptionObject - JSON object containing subscription information such as the topic and type
      listener - EventListener that was registered before
      callback - AckListener for this request
      source - source of this request
    • respondToPing

      protected void respondToPing​(long pingId)
    • addExternalMessageHandler

      public void addExternalMessageHandler​(ExternalMessageListener listener, java.lang.Object source)
      Registers a listener to handle messages for this connection's UUID originating via HTTPS/HTTP
      Parameters:
      listener - process a received HTTPS/HTTP message for this connection
      source - The object that originally registered the listener
    • setAdditionalRuntimeArguments

      public void setAdditionalRuntimeArguments​(java.lang.String additionalRuntimeArguments)
      Deprecated.
      Set additional runtime arguments passed to the Runtime
      Parameters:
      additionalRuntimeArguments - additional arguments, such as "--v=1" to enable more logging
    • setAdditionalRvmArguments

      public void setAdditionalRvmArguments​(java.lang.String additionalRvmArguments)
      Deprecated.
      Set additional runtime arguments passed to the RVM
      Parameters:
      additionalRvmArguments - additional arguments
    • setRuntimeSecurityRealm

      public void setRuntimeSecurityRealm​(java.lang.String runtimeSecurityRealm)
      Deprecated.
      Set security realm of the Runtime
      Parameters:
      runtimeSecurityRealm - name of the realm
    • setRdmUrl

      public void setRdmUrl​(java.lang.String url)
      Set URL of RDM service
      Parameters:
      url - URL of RDM service
    • setDevToolsPort

      public void setDevToolsPort​(int port)
      Deprecated.
      Set port for accessing devtools on localhost
      Parameters:
      port - port number
    • setLogLevel

      public void setLogLevel​(boolean enabled)
      Deprecated.
      Set log level to be FINE
      Parameters:
      enabled - true for enabling DEBUG logging
    • getChannel

      public Channel getChannel​(java.lang.String name)
      Gets specified channel.
      Parameters:
      name - Name of the channel
      Returns:
      Channel object with the given name.
    • getInterop

      public Interop getInterop()
      Gets Interop API object.
      Returns:
      an instance of Interop
    • getSnapshotSource

      public SnapshotSource getSnapshotSource()
      Gets SnapshotSource API object
      Returns:
      an instance of SnapshotSource
    • getUuid

      public java.lang.String getUuid()
      Gets the UUID of this connection.
      Returns:
      uuid of the connection.