Package com.openfin.desktop.channel
Class AbstractProtocolHandler
- java.lang.Object
-
- com.openfin.desktop.channel.AbstractProtocolHandler
-
- Direct Known Subclasses:
ClassicProtocolHandler,WebRtcProtocolHandler
public class AbstractProtocolHandler extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description protected Channelchannelprotected EndpointIdentityclientEndpointIdentityprotected EndpointIdentityendpointIdentityprotected booleanisProviderprotected org.slf4j.Loggerlogger
-
Constructor Summary
Constructors Constructor Description AbstractProtocolHandler(Channel channel)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidacceptAnswer(org.json.JSONObject answer, java.util.concurrent.CompletableFuture<java.lang.Boolean> future)protected voidacceptOffer(org.json.JSONObject offer)protected voidcleanup()static AbstractProtocolHandlercreateProtocolHandler(ProtocolOptions options, Channel channel)ChannelgetChannel()org.json.JSONObjectgetChannelConnectPayload(java.lang.Object connectPayload)create payload for connecting to provider.org.json.JSONObjectgetChannelCreatePayload()static org.json.JSONObjectgetOfferProtocolByType(org.json.JSONObject offer, ProtocolOptions options)ProtocolOptionsgetProtocolOptions()protected org.json.JSONObjectgetSupportedAnswerProtocol()protected org.json.JSONObjectgetSupportedOfferProtocol()voidinitializeClient()voidinitializeProvider(EndpointIdentity endpointIdentity, EndpointIdentity clientEndpointIdentity)java.util.concurrent.CompletionStage<java.lang.Boolean>processConnectAnswer(org.json.JSONObject res)Process connection answer response from a channel provider with connect-to-channel messageorg.json.JSONObjectprocessConnectOffer(org.json.JSONObject offer)Process connection offer from a channel client for a providervoidsendChannelMessage(java.lang.String action, org.json.JSONObject destionationIdentity, org.json.JSONObject providerIdentity, org.json.JSONObject actionPayload, AckListener ackListener)java.util.concurrent.CompletableFuture<Ack>sendChannelMessageAsync(java.lang.String action, org.json.JSONObject destionationIdentity, org.json.JSONObject providerIdentity, java.lang.Object actionPayload)voidsetClientEndpointIdentity(EndpointIdentity endpointIdentity)
-
-
-
Field Detail
-
logger
protected org.slf4j.Logger logger
-
channel
protected Channel channel
-
isProvider
protected boolean isProvider
-
endpointIdentity
protected EndpointIdentity endpointIdentity
-
clientEndpointIdentity
protected EndpointIdentity clientEndpointIdentity
-
-
Constructor Detail
-
AbstractProtocolHandler
public AbstractProtocolHandler(Channel channel)
-
-
Method Detail
-
createProtocolHandler
public static AbstractProtocolHandler createProtocolHandler(ProtocolOptions options, Channel channel)
-
getProtocolOptions
public ProtocolOptions getProtocolOptions()
-
getChannelConnectPayload
public org.json.JSONObject getChannelConnectPayload(java.lang.Object connectPayload) throws java.lang.Exceptioncreate payload for connecting to provider. The payload include "offer" object- Returns:
- connect payload
- Throws:
java.lang.Exception- Exception
-
getSupportedOfferProtocol
protected org.json.JSONObject getSupportedOfferProtocol()
-
setClientEndpointIdentity
public void setClientEndpointIdentity(EndpointIdentity endpointIdentity)
-
processConnectAnswer
public java.util.concurrent.CompletionStage<java.lang.Boolean> processConnectAnswer(org.json.JSONObject res)
Process connection answer response from a channel provider with connect-to-channel message- Parameters:
res- response from a provider- Returns:
- CompletionStage with true as the answer is accepted
-
acceptAnswer
protected void acceptAnswer(org.json.JSONObject answer, java.util.concurrent.CompletableFuture<java.lang.Boolean> future) throws java.lang.Exception- Throws:
java.lang.Exception
-
getChannelCreatePayload
public org.json.JSONObject getChannelCreatePayload()
-
getSupportedAnswerProtocol
protected org.json.JSONObject getSupportedAnswerProtocol()
-
processConnectOffer
public org.json.JSONObject processConnectOffer(org.json.JSONObject offer)
Process connection offer from a channel client for a provider- Parameters:
offer- offer object from channel client- Returns:
- answer object if the offer is accepted
-
acceptOffer
protected void acceptOffer(org.json.JSONObject offer) throws java.lang.Exception- Throws:
java.lang.Exception
-
getChannel
public Channel getChannel()
-
initializeClient
public void initializeClient() throws java.lang.Exception- Throws:
java.lang.Exception
-
initializeProvider
public void initializeProvider(EndpointIdentity endpointIdentity, EndpointIdentity clientEndpointIdentity) throws java.lang.Exception
- Throws:
java.lang.Exception
-
sendChannelMessage
public void sendChannelMessage(java.lang.String action, org.json.JSONObject destionationIdentity, org.json.JSONObject providerIdentity, org.json.JSONObject actionPayload, AckListener ackListener)
-
sendChannelMessageAsync
public java.util.concurrent.CompletableFuture<Ack> sendChannelMessageAsync(java.lang.String action, org.json.JSONObject destionationIdentity, org.json.JSONObject providerIdentity, java.lang.Object actionPayload)
-
cleanup
protected void cleanup()
-
getOfferProtocolByType
public static org.json.JSONObject getOfferProtocolByType(org.json.JSONObject offer, ProtocolOptions options)
-
-