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 Channel
channel
protected EndpointIdentity
clientEndpointIdentity
protected EndpointIdentity
endpointIdentity
protected boolean
isProvider
protected org.slf4j.Logger
logger
-
Constructor Summary
Constructors Constructor Description AbstractProtocolHandler(Channel channel)
-
Method Summary
Modifier and Type Method Description protected void
acceptAnswer(org.json.JSONObject answer, java.util.concurrent.CompletableFuture<java.lang.Boolean> future)
protected void
acceptOffer(org.json.JSONObject offer)
protected void
cleanup()
static AbstractProtocolHandler
createProtocolHandler(ProtocolOptions options, Channel channel)
Channel
getChannel()
org.json.JSONObject
getChannelConnectPayload(java.lang.Object connectPayload)
create payload for connecting to provider.org.json.JSONObject
getChannelCreatePayload()
static org.json.JSONObject
getOfferProtocolByType(org.json.JSONObject offer, ProtocolOptions options)
ProtocolOptions
getProtocolOptions()
protected org.json.JSONObject
getSupportedAnswerProtocol()
protected org.json.JSONObject
getSupportedOfferProtocol()
void
initializeClient()
void
initializeProvider(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.JSONObject
processConnectOffer(org.json.JSONObject offer)
Process connection offer from a channel client for a providervoid
sendChannelMessage(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)
void
setClientEndpointIdentity(EndpointIdentity endpointIdentity)
-
Field Details
-
logger
protected org.slf4j.Logger logger -
channel
-
isProvider
protected boolean isProvider -
endpointIdentity
-
clientEndpointIdentity
-
-
Constructor Details
-
Method Details
-
createProtocolHandler
public static AbstractProtocolHandler createProtocolHandler(ProtocolOptions options, Channel channel) -
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
-
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
-
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)
-