Package com.openfin.desktop.channel
Class Channel
- java.lang.Object
-
- com.openfin.desktop.channel.Channel
-
public class Channel extends Object
The Channel object allows an OpenFin application to create a channel as a ChannelProvider, or connect to a channel as a ChannelClient.- Author:
- Anthony
-
-
Constructor Summary
Constructors Constructor Description Channel(String name, DesktopConnection desktopConnection)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddChannelListener(ChannelListener listener)voidaddEventListener(String type, EventListener listener, AckListener callback)Registers an event listener on the specified eventprotected voidaddEventListener(org.json.JSONObject subscriptionObject, EventListener listener, AckListener callback)Registers an event listener on the specified eventvoidconnect(AsyncCallback<ChannelClient> callback)Connect to the channel.CompletionStage<ChannelClient>connectAsync()Connect to a channel providerCompletionStage<ChannelClient>connectAsync(Boolean noWait, Object connectPayload)Connect to a channel provider with a payload passed to the providerCompletionStage<ChannelClient>connectAsync(Object connectPayload)Connect to a channel provider with a payload passed to the providervoidcreate(AsyncCallback<ChannelProvider> callback)Create a new channel.CompletionStage<ChannelProvider>createAsync()protected voidfireChannelConnectEvent(ConnectionEvent event)protected voidfireChannelDisconnectEvent(ConnectionEvent event)DesktopConnectiongetDesktopConnection()StringgetName()Get the name of the channelbooleanhasClient()Check if the channel has client connectedbooleanhasProvider()Check if the channel has provider createdObjectinvokeAction(EndpointIdentity targetIdentity, String action, Object actionPayload, org.json.JSONObject senderIdentity)voidprocessConnection(org.json.JSONObject payload)booleanremoveChannelListener(ChannelListener listener)voidremoveEventListener(String type, EventListener listener, AckListener callback)Removes a previously registered event listener from the specified event
-
-
-
Constructor Detail
-
Channel
public Channel(String name, DesktopConnection desktopConnection)
-
-
Method Detail
-
getName
public String getName()
Get the name of the channel- Returns:
- name of the channel
-
getDesktopConnection
public DesktopConnection getDesktopConnection()
-
createAsync
public CompletionStage<ChannelProvider> createAsync()
-
create
public void create(AsyncCallback<ChannelProvider> callback)
Create a new channel.- Parameters:
callback- The callback that receives the wrappedChannelProviderobject
-
connectAsync
public CompletionStage<ChannelClient> connectAsync()
Connect to a channel provider- Returns:
- A new CompletionStage for the client client
-
connectAsync
public CompletionStage<ChannelClient> connectAsync(Object connectPayload)
Connect to a channel provider with a payload passed to the provider- Parameters:
connectPayload- connection payload- Returns:
- A new CompletionStage for the channel client
-
connectAsync
public CompletionStage<ChannelClient> connectAsync(Boolean noWait, Object connectPayload)
Connect to a channel provider with a payload passed to the provider- Parameters:
noWait- if true, the request will fail if the provider is not runningconnectPayload- connection payload- Returns:
- A new CompletionStage for the client client
-
connect
public void connect(AsyncCallback<ChannelClient> callback)
Connect to the channel.- Parameters:
callback- The callback that receives the wrappedChannelClientobject
-
hasProvider
public boolean hasProvider()
Check if the channel has provider created- Returns:
- if the channel provider exists.
-
hasClient
public boolean hasClient()
Check if the channel has client connected- Returns:
- true if a channel client exists
-
invokeAction
public Object invokeAction(EndpointIdentity targetIdentity, String action, Object actionPayload, org.json.JSONObject senderIdentity)
-
addChannelListener
public boolean addChannelListener(ChannelListener listener)
-
removeChannelListener
public boolean removeChannelListener(ChannelListener listener)
-
fireChannelConnectEvent
protected void fireChannelConnectEvent(ConnectionEvent event)
-
fireChannelDisconnectEvent
protected void fireChannelDisconnectEvent(ConnectionEvent event)
-
processConnection
public void processConnection(org.json.JSONObject payload) throws Exception- Throws:
Exception
-
addEventListener
protected void addEventListener(org.json.JSONObject subscriptionObject, EventListener listener, AckListener callback) throws DesktopExceptionRegisters an event listener on the specified eventSupported system event types are:- Parameters:
subscriptionObject- A JSON object containing subscription information such as the topic and typelistener- EventListener for the eventcallback- AckListener for the request- Throws:
DesktopException- if this method fails to add event listener specified- See Also:
EventListener,AckListener
-
addEventListener
public void addEventListener(String type, EventListener listener, AckListener callback) throws DesktopException
Registers an event listener on the specified eventSupported system event types are:- Parameters:
type- Type of the eventlistener- EventListener for the eventcallback- AckListener for the request- Throws:
DesktopException- if this method fails to add event listener specified- See Also:
EventListener,AckListener
-
removeEventListener
public void removeEventListener(String type, EventListener listener, AckListener callback) throws DesktopException
Removes a previously registered event listener from the specified event- Parameters:
type- Type of the eventlistener- EventListener for the eventcallback- AckListener for the request- Throws:
DesktopException- if this method fails to remove event listener specified- See Also:
DesktopException,EventListener,AckListener
-
-