com.openfin.desktop
Class InterApplicationBus

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

public class InterApplicationBus
extends Object

A messaging bus that allows for pub / sub messaging between different applications. Available via getInterApplicationBus() method on DesktopConnection


Constructor Summary
InterApplicationBus(DesktopConnection desktopConnection)
          Constructor
 
Method Summary
 void addSubscribeListener(SubscriptionListener listener)
          Registers a listener which is called whenever a subscription occurs.
protected  void dispatchMessageToCallbacks(String sourceUuid, String topic, Object message)
          Dispatches a messages to listeners
 void dispatchToSubscribeListeners(String uuid, String topic)
          Dispatches to subscription listeners
 void dispatchToUnsubscribeListeners(String uuid, String topic)
          Dispatches to unsubscription listeners
static void publish(String topic, Object message)
          Publishes a message to a topic
 void removeSubscribeListener(SubscriptionListener listener)
          Removes the passed listener.
static void send(String destinationUuid, String topic, Object message)
          Sends a message to an application
static void subscribe(String sourceUuid, String topic, BusListener listener)
          Subscribes to messages on the specified topic
static void unsubscribe(String sourceUuid, String topic, BusListener listener)
          Unsubscribes to messages on the specified topic
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InterApplicationBus

public InterApplicationBus(DesktopConnection desktopConnection)
Constructor

Parameters:
desktopConnection - Connection object to the AppDesktop
Method Detail

publish

public static void publish(String topic,
                           Object message)
                    throws DesktopIOException,
                           DesktopException
Publishes a message to a topic

Parameters:
topic - Topic to which the message is published
message - The JSON message to publish *
Throws:
DesktopIOException
DesktopException
See Also:
DesktopIOException, DesktopException

send

public static void send(String destinationUuid,
                        String topic,
                        Object message)
                 throws DesktopIOException,
                        DesktopException
Sends a message to an application

Parameters:
destinationUuid - UUID of the application from which messages are sent
topic - Topic to which the message is published
message - The JSON message to publish
Throws:
DesktopIOException
DesktopException
See Also:
DesktopIOException, DesktopException

subscribe

public static void subscribe(String sourceUuid,
                             String topic,
                             BusListener listener)
                      throws DesktopIOException,
                             DesktopException
Subscribes to messages on the specified topic

Parameters:
sourceUuid - The UUID of the application to which to subscribe. The wildcard "*" can be used to receive messages from all applications
topic - The topic to be subscribed to
listener - BusListener for the subscription
Throws:
DesktopIOException
DesktopException
See Also:
BusListener, DesktopIOException, DesktopException

unsubscribe

public static void unsubscribe(String sourceUuid,
                               String topic,
                               BusListener listener)
                        throws DesktopIOException,
                               DesktopException
Unsubscribes to messages on the specified topic

Parameters:
sourceUuid - UUID of the application
topic - The topic to be subscribed to
listener - BusListener for the subscription
Throws:
DesktopIOException
DesktopException
See Also:
BusListener, DesktopIOException, DesktopException

dispatchMessageToCallbacks

protected void dispatchMessageToCallbacks(String sourceUuid,
                                          String topic,
                                          Object message)
Dispatches a messages to listeners

Parameters:
sourceUuid - UUID of the application from which messages are sent
topic - Topic to which the mssage is published
message - The JSON message to be dispatched

addSubscribeListener

public void addSubscribeListener(SubscriptionListener listener)
Registers a listener which is called whenever a subscription occurs. A function that is called whenever a subscription occurs. It is passed the topic and application UUID that trigered the event.

Parameters:
listener - Listener to add

removeSubscribeListener

public void removeSubscribeListener(SubscriptionListener listener)
Removes the passed listener. It is no longer called for subscription events.

Parameters:
listener - Listener to remove

dispatchToSubscribeListeners

public void dispatchToSubscribeListeners(String uuid,
                                         String topic)
Dispatches to subscription listeners

Parameters:
uuid - The subscribing application
topic - The topic that is subscribed to

dispatchToUnsubscribeListeners

public void dispatchToUnsubscribeListeners(String uuid,
                                           String topic)
Dispatches to unsubscription listeners

Parameters:
uuid - The unsubscribing application
topic - The topic that was subscribed to


Copyright © 2015. All rights reserved.