Package com.openfin.desktop.channel
Class ChannelBase
- java.lang.Object
-
- com.openfin.desktop.channel.ChannelBase
-
- Direct Known Subclasses:
ChannelClient,ChannelProvider
public class ChannelBase extends Object
-
-
Field Summary
Fields Modifier and Type Field Description protected MiddlewareafterActionprotected MiddlewarebeforeActionprotected Channelchannelprotected ConcurrentHashMap<String,ChannelAction>channelActionMapprotected MiddlewaredefaultActionprotected EndpointIdentityendpointIdentityprotected MiddlewareonError
-
Constructor Summary
Constructors Constructor Description ChannelBase(Channel channel, EndpointIdentity endpointIdentity)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddispatch(org.json.JSONObject destinationIdentity, String action, org.json.JSONObject actionPayload, AckListener ackListener)Dispatch an action to a specified client.CompletableFuture<Ack>dispatchAsync(org.json.JSONObject destinationIdentity, String action, Object actionPayload)StringgetChannelId()StringgetChannelName()StringgetEndpointId()EndpointIdentitygetEndpointIdentity()StringgetName()StringgetUuid()booleanhasRegisteredAction(String action)protected booleanregister(String action, ChannelAction listener)booleanremove(String action)remove the registered actionvoidsetAfterAction(Middleware middleware)Register an action that fires after the action.voidsetBeforeAction(Middleware middleware)Register an action that fires before the action.voidsetDefaultAction(Middleware middleware)Sets a default action.voidsetOnError(Middleware middleware)Register an error handler.
-
-
-
Field Detail
-
defaultAction
protected Middleware defaultAction
-
onError
protected Middleware onError
-
beforeAction
protected Middleware beforeAction
-
afterAction
protected Middleware afterAction
-
channelActionMap
protected ConcurrentHashMap<String,ChannelAction> channelActionMap
-
channel
protected Channel channel
-
endpointIdentity
protected EndpointIdentity endpointIdentity
-
-
Constructor Detail
-
ChannelBase
public ChannelBase(Channel channel, EndpointIdentity endpointIdentity)
-
-
Method Detail
-
register
protected boolean register(String action, ChannelAction listener)
-
remove
public boolean remove(String action)
remove the registered action- Parameters:
action- Name of the action to be removed.- Returns:
- if the action was removed successfully
-
setDefaultAction
public void setDefaultAction(Middleware middleware)
Sets a default action. This is used any time an action that has not been registered is invoked.- Parameters:
middleware- Action to be executed when a client invokes an action name that has not been registered.
-
setOnError
public void setOnError(Middleware middleware)
Register an error handler. This is called before responding on any error.- Parameters:
middleware- Action to be executed in case of an error.
-
setBeforeAction
public void setBeforeAction(Middleware middleware)
Register an action that fires before the action.- Parameters:
middleware- Action to be executed before invoking the action.
-
setAfterAction
public void setAfterAction(Middleware middleware)
Register an action that fires after the action.- Parameters:
middleware- Action to be executed after invoking the action.
-
getEndpointIdentity
public EndpointIdentity getEndpointIdentity()
-
getChannelName
public String getChannelName()
-
getUuid
public String getUuid()
-
getChannelId
public String getChannelId()
-
getName
public String getName()
-
getEndpointId
public String getEndpointId()
-
hasRegisteredAction
public boolean hasRegisteredAction(String action)
-
dispatch
public void dispatch(org.json.JSONObject destinationIdentity, String action, org.json.JSONObject actionPayload, AckListener ackListener)Dispatch an action to a specified client.- Parameters:
destinationIdentity- Identity of the target client.action- Name of the action to be invoked by the client.actionPayload- Payload to be sent along with the action.ackListener- AckListener for the request
-
dispatchAsync
public CompletableFuture<Ack> dispatchAsync(org.json.JSONObject destinationIdentity, String action, Object actionPayload)
-
-