Class 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
    • Constructor Detail

      • Channel

        public Channel​(java.lang.String name,
                       DesktopConnection desktopConnection)
    • Method Detail

      • getName

        public java.lang.String getName()
        Get the name of the channel
        Returns:
        name of the channel
      • createAsync

        public java.util.concurrent.CompletionStage<ChannelProvider> createAsync()
      • connectAsync

        public java.util.concurrent.CompletionStage<ChannelClient> 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 payload
        protocolType - 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 active
        connectPayload - connection payload
        protocolType - requested protocol type for the channel
        Returns:
        A new CompletionStage for the channel client
      • 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

        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,
                                      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 DesktopException
        Registers an event listener on the specified event
             Supported system event types are:
         
        Parameters:
        subscriptionObject - A JSON object containing subscription information such as the topic and type
        listener - EventListener for the event
        callback - 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 DesktopException
        Registers an event listener on the specified event
             Supported system event types are:
         
        Parameters:
        type - Type of the event
        listener - EventListener for the event
        callback - AckListener for the request
        Throws:
        DesktopException - if this method fails to add event listener specified
        See Also:
        EventListener, AckListener
      • raiseEvent

        public java.util.concurrent.CompletableFuture<Ack> raiseEvent​(java.lang.String type,
                                                                      org.json.JSONObject eventObject)
                                                               throws DesktopException
        Raise a channel event to Runtime
        Parameters:
        type - type of event
        eventObject - event payload
        Returns:
        CompletableFuture with Ack object
        Throws:
        DesktopException - DesktopException
        See Also:
        Ack