com.openfin.desktop
Class DesktopConnection

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

public class DesktopConnection
extends Object

A object for launching, connecting to, and controlling AppDesktop.


Constructor Summary
DesktopConnection(String uuid)
          Creates a new connection to AppDesktop
DesktopConnection(String uuid, String host, Integer port)
          Creates a new connection to AppDesktop
 
Method Summary
 void addEventCallback(org.json.JSONObject subscriptionObject, EventListener listener, AckListener callback, Object source)
          Registers an event listener on the specified event
 void addExternalMessageHandler(ExternalMessageListener listener, Object source)
          Registers a listener to handle messages for this connection's UUID originating via HTTPS/HTTP
 void connect(DesktopStateListener listener)
          Connects to an AppDesktop process
 void connectToVersion(String desktopVersion, DesktopStateListener listener, int timeout)
          Connect to specified version of Desktop.
 void disconnect()
          Disconnects from AppDesktop
 void exit()
          Notify AppDesktop to exit
 InterApplicationBus getInterApplicationBus()
          Gets the Inter-Application message dispatcher associated with this DesktopConnection
 boolean isConnected()
          InterApplicationBus
 void launchAndConnect(String commandLineArguments, DesktopStateListener listener, int timeout)
          Launches AppDesktop and notifies the listener when connected.
 void launchAndConnect(String desktopPath, String commandLineArguments, DesktopStateListener listener, int timeout)
          Launches AppDesktop and notifies the listener when connected.
protected  void log(String text)
          Logging info
 Integer registerNotificationListener(NotificationListener listener, Object source)
          Registers listener for a new notification
 void removeEventCallback(org.json.JSONObject subscriptionObject, EventListener listener, AckListener callback, Object source)
          Removes a previously registered event listener from the specified event
protected  void respondToPing(long pingId)
           
 void sendAction(String action, org.json.JSONObject payload)
          Sends a message to AppDesktop
 void sendAction(String action, org.json.JSONObject payload, AckListener listener, Object source)
          Sends a message to AppDesktop
 void sendActionToNotificationsCenter(String action, org.json.JSONObject payload, AckListener callback, Object source)
           
 void setLogLevel(boolean enabled)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DesktopConnection

public DesktopConnection(String uuid)
                  throws DesktopException
Creates a new connection to AppDesktop

Parameters:
uuid - unique ID for AppDesktop to refer to this DesktopConnection
Throws:
DesktopException

DesktopConnection

public DesktopConnection(String uuid,
                         String host,
                         Integer port)
                  throws DesktopException
Creates a new connection to AppDesktop

Parameters:
uuid - unique ID for AppDesktop to refer to this DesktopConnection
host - The host that AppDesktop is running on
port - The port that AppDesktop is listening on for connections. -null if unknown
Throws:
DesktopException
Method Detail

launchAndConnect

public void launchAndConnect(String commandLineArguments,
                             DesktopStateListener listener,
                             int timeout)
                      throws URISyntaxException,
                             DesktopIOException
Launches AppDesktop and notifies the listener when connected. This method launches OpenFinRVM.exe embedded in the jar.

Parameters:
commandLineArguments - Command line arguments to start the AppDesktop with
listener - Receives updates on startup and connection state
timeout - For connecting to Desktop after launch. If the connection to AppDesktop is not established by the timeout the listener will get an onError() call
Throws:
URISyntaxException
DesktopIOException

launchAndConnect

public void launchAndConnect(String desktopPath,
                             String commandLineArguments,
                             DesktopStateListener listener,
                             int timeout)
                      throws URISyntaxException,
                             DesktopIOException
Launches AppDesktop and notifies the listener when connected.

Parameters:
desktopPath - Absolute path to the AppDesktop executable
commandLineArguments - Command line arguments to start the AppDesktop with
listener - Receives updates on startup and connection state
timeout - For connecting to Desktop after launch. If the connection to AppDesktop is not established by the timeout the listener will get an onError() call
Throws:
URISyntaxException
DesktopIOException

connectToVersion

public void connectToVersion(String desktopVersion,
                             DesktopStateListener listener,
                             int timeout)
                      throws URISyntaxException,
                             DesktopIOException,
                             IOException
Connect to specified version of Desktop. If the specified version is not running, this method will try to start it.

Parameters:
desktopVersion - version of Desktop required
listener - Receives updates on startup and connection state
timeout - For connecting to Desktop after launch. If the connection to AppDesktop is not established by the timeout the listener will get an onError() call
Throws:
URISyntaxException
DesktopIOException
IOException

disconnect

public void disconnect()
Disconnects from AppDesktop


isConnected

public boolean isConnected()
InterApplicationBus

Returns:
true if connected

exit

public void exit()
Notify AppDesktop to exit


getInterApplicationBus

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

Returns:
InterApplicationBus

sendAction

public void sendAction(String action,
                       org.json.JSONObject payload)
                throws DesktopException,
                       DesktopIOException
Sends a message to AppDesktop

Parameters:
action - The action of the message
payload - The message object to send
Throws:
DesktopException
DesktopIOException

sendAction

public void sendAction(String action,
                       org.json.JSONObject payload,
                       AckListener listener,
                       Object source)
Sends a message to AppDesktop

Parameters:
action - The action of the message
payload - The message object to send
listener - AckListener for the message
source - Message source
See Also:
AckListener

connect

public void connect(DesktopStateListener listener)
             throws URISyntaxException,
                    DesktopIOException
Connects to an AppDesktop process

Parameters:
listener - Receives updates on startup and connection state
Throws:
URISyntaxException
DesktopIOException
See Also:
DesktopStateListener

registerNotificationListener

public Integer registerNotificationListener(NotificationListener listener,
                                            Object source)
Registers listener for a new notification

Parameters:
listener - NotificationListener for the notification
source - Source of the request
Returns:
Notification Id
See Also:
NotificationListener

sendActionToNotificationsCenter

public void sendActionToNotificationsCenter(String action,
                                            org.json.JSONObject payload,
                                            AckListener callback,
                                            Object source)

addEventCallback

public void addEventCallback(org.json.JSONObject subscriptionObject,
                             EventListener listener,
                             AckListener callback,
                             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

removeEventCallback

public void removeEventCallback(org.json.JSONObject subscriptionObject,
                                EventListener listener,
                                AckListener callback,
                                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,
                                      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

setLogLevel

public void setLogLevel(boolean enabled)

log

protected void log(String text)
Logging info

Parameters:
text - The text to be logged


Copyright © 2015. All rights reserved.