Class EventStreamRPCConnection
- java.lang.Object
-
- software.amazon.awssdk.eventstreamrpc.EventStreamRPCConnection
-
- All Implemented Interfaces:
AutoCloseable
public class EventStreamRPCConnection extends Object implements AutoCloseable
A connection for an EventStreamRPC client
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
EventStreamRPCConnection.LifecycleHandler
Lifecycle handler is how a client can react and respond to connectivity interruptions.
-
Constructor Summary
Constructors Constructor Description EventStreamRPCConnection(EventStreamRPCConnectionConfig config)
Constructs a new EventStreamRPCConnection from the given configuration
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
CompletableFuture<Void>
connect(EventStreamRPCConnection.LifecycleHandler lifecycleHandler)
Connects to the event stream RPC server asynchronouslyvoid
disconnect()
Disconnects the EventStreamRPCConnectionsoftware.amazon.awssdk.crt.eventstream.ClientConnectionContinuation
newStream(software.amazon.awssdk.crt.eventstream.ClientConnectionContinuationHandler continuationHandler)
Creates a new stream with the given continuation handler.CompletableFuture<Void>
sendPing(Optional<MessageAmendInfo> pingData)
Interface to send ping.CompletableFuture<Void>
sendPingResponse(Optional<MessageAmendInfo> pingResponseData)
Interface to send pingResponse.
-
-
-
Constructor Detail
-
EventStreamRPCConnection
public EventStreamRPCConnection(EventStreamRPCConnectionConfig config)
Constructs a new EventStreamRPCConnection from the given configuration- Parameters:
config
- The configuration used to construct the EventStreamRPCConnection
-
-
Method Detail
-
connect
public CompletableFuture<Void> connect(EventStreamRPCConnection.LifecycleHandler lifecycleHandler)
Connects to the event stream RPC server asynchronously- Returns:
- A future that completes when connected
-
newStream
public software.amazon.awssdk.crt.eventstream.ClientConnectionContinuation newStream(software.amazon.awssdk.crt.eventstream.ClientConnectionContinuationHandler continuationHandler)
Creates a new stream with the given continuation handler. Trhows an exception if not connected- Parameters:
continuationHandler
- The continuation handler to use- Returns:
- A new ClientConnectionContinuation containing the new stream.
-
disconnect
public void disconnect()
Disconnects the EventStreamRPCConnection
-
sendPing
public CompletableFuture<Void> sendPing(Optional<MessageAmendInfo> pingData)
Interface to send ping. Optional MessageAmendInfo will use the headers and payload for the ping message verbatim. Should trigger a pong response and server copies back- Parameters:
pingData
- The ping data to send- Returns:
- A future that completes when the pong response is receieved
-
sendPingResponse
public CompletableFuture<Void> sendPingResponse(Optional<MessageAmendInfo> pingResponseData)
Interface to send pingResponse. Optional MessageAmendInfo will use the headers and payload for the ping message verbatim. Should trigger a pong response and server copies back- Parameters:
pingResponseData
- The ping response data to send- Returns:
- A future that completes when the pong response is receieved
-
close
public void close()
- Specified by:
close
in interfaceAutoCloseable
-
-