Package com.openfin.desktop.channel
Class Channel
java.lang.Object
com.openfin.desktop.channel.Channel
public class Channel
extends java.lang.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
-
Field Summary
Fields Modifier and Type Field Description static ProtocolOptions
CLASSIC_PROTOCOL
static ProtocolOptions
RTC_PROTOCOL
-
Constructor Summary
Constructors Constructor Description Channel(java.lang.String name, DesktopConnection desktopConnection)
-
Method Summary
Modifier and Type Method Description boolean
addChannelListener(ChannelListener listener)
void
addEventListener(java.lang.String type, EventListener listener, AckListener callback)
Registers an event listener on the specified eventprotected void
addEventListener(org.json.JSONObject subscriptionObject, EventListener listener, AckListener callback)
Registers an event listener on the specified eventvoid
connect(AsyncCallback<ChannelClient> callback)
Deprecated.useconnectAsync(Object)
insteadvoid
connect(ProtocolOptions protocolType, AsyncCallback<ChannelClient> callback)
Deprecated.useconnectAsync(Object, ProtocolOptions)
} insteadjava.util.concurrent.CompletionStage<ChannelClient>
connectAsync()
Connect to a channel providerjava.util.concurrent.CompletionStage<ChannelClient>
connectAsync(java.lang.Boolean noWait, java.lang.Object connectPayload, ProtocolOptions protocolType)
Connect to a channel providerjava.util.concurrent.CompletionStage<ChannelClient>
connectAsync(java.lang.Object connectPayload)
Connect to a channel providerjava.util.concurrent.CompletionStage<ChannelClient>
connectAsync(java.lang.Object connectPayload, ProtocolOptions protocolType)
Connect to a channel providervoid
create(AsyncCallback<ChannelProvider> callback)
void
create(AsyncCallback<ChannelProvider> callback, ProtocolOptions protocolType)
Deprecated.usecreateAsync()
insteadjava.util.concurrent.CompletionStage<ChannelProvider>
createAsync()
java.util.concurrent.CompletionStage<ChannelProvider>
createAsync(java.util.List<ProtocolOptions> protocolList)
protected void
fireChannelConnectEvent(ConnectionEvent event)
protected void
fireChannelDisconnectEvent(ConnectionEvent event)
DesktopConnection
getDesktopConnection()
java.lang.String
getName()
Get the name of the channelboolean
hasClient()
Check if the channel has client connectedboolean
hasProvider()
Check if the channel has provider createdjava.lang.Object
invokeAction(EndpointIdentity targetIdentity, java.lang.String action, java.lang.Object actionPayload, org.json.JSONObject senderIdentity)
void
processConnection(org.json.JSONObject payload, org.json.JSONObject ackToSenderPayload)
java.util.concurrent.CompletableFuture<Ack>
raiseEvent(java.lang.String type, org.json.JSONObject eventObject)
Raise a channel event to Runtimeboolean
removeChannelListener(ChannelListener listener)
void
removeEventListener(java.lang.String type, EventListener listener, AckListener callback)
Removes a previously registered event listener from the specified event
-
Field Details
-
Constructor Details
-
Method Details
-
getName
public java.lang.String getName()Get the name of the channel- Returns:
- name of the channel
-
getDesktopConnection
-
createAsync
-
createAsync
public java.util.concurrent.CompletionStage<ChannelProvider> createAsync(java.util.List<ProtocolOptions> protocolList) -
create
-
create
Deprecated.usecreateAsync()
insteadCreate a new channel.- Parameters:
callback
- The callback that receives the wrappedChannelProvider
objectprotocolType
- Type of protocol (CLASSIC or RTC)
-
connectAsync
Connect to a channel provider- Returns:
- A new CompletionStage for the channel client
-
connectAsync
public java.util.concurrent.CompletionStage<ChannelClient> connectAsync(java.lang.Object connectPayload)Connect to a channel provider- Parameters:
connectPayload
- connection payload- Returns:
- A new CompletionStage for the channel client
-
connectAsync
public java.util.concurrent.CompletionStage<ChannelClient> connectAsync(java.lang.Object connectPayload, ProtocolOptions protocolType)Connect to a channel provider- Parameters:
connectPayload
- connection payloadprotocolType
- requested protocol type for the channel- Returns:
- A new CompletionStage for the channel client
-
connectAsync
public java.util.concurrent.CompletionStage<ChannelClient> connectAsync(java.lang.Boolean noWait, java.lang.Object connectPayload, ProtocolOptions protocolType)Connect to a channel provider- Parameters:
noWait
- true if the request does not wait when the channel provider is not activeconnectPayload
- connection payloadprotocolType
- requested protocol type for the channel- Returns:
- A new CompletionStage for the channel client
-
connect
Deprecated.useconnectAsync(Object)
insteadConnect to the channel.- Parameters:
callback
- The callback that receives the wrappedChannelClient
object
-
connect
Deprecated.useconnectAsync(Object, ProtocolOptions)
} insteadConnect to the channel.- Parameters:
callback
- The callback that receives the wrappedChannelClient
objectprotocolType
- Type of protocol ("classic" or "rtc")
-
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 java.lang.Object invokeAction(EndpointIdentity targetIdentity, java.lang.String action, java.lang.Object actionPayload, org.json.JSONObject senderIdentity) -
addChannelListener
-
removeChannelListener
-
fireChannelConnectEvent
-
fireChannelDisconnectEvent
-
processConnection
public void processConnection(org.json.JSONObject payload, org.json.JSONObject ackToSenderPayload) throws java.lang.Exception- Throws:
java.lang.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(java.lang.String type, EventListener listener, AckListener callback) throws DesktopExceptionRegisters 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(java.lang.String type, EventListener listener, AckListener callback) throws DesktopExceptionRemoves 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
-
raiseEvent
public java.util.concurrent.CompletableFuture<Ack> raiseEvent(java.lang.String type, org.json.JSONObject eventObject) throws DesktopExceptionRaise a channel event to Runtime- Parameters:
type
- type of eventeventObject
- event payload- Returns:
- CompletableFuture with Ack object
- Throws:
DesktopException
- DesktopException- See Also:
Ack
-