Class ServerConnection
java.lang.Object
software.amazon.awssdk.crt.CrtResource
software.amazon.awssdk.crt.eventstream.ServerConnection
- All Implemented Interfaces:
AutoCloseable
Wrapper around event-stream-rpc-server-connection. Note this class is AutoClosable.
By default the ServerConnectionHandler::onClosed callback calls close().
-
Nested Class Summary
Nested classes/interfaces inherited from class software.amazon.awssdk.crt.CrtResource
CrtResource.ResourceInstance -
Method Summary
Modifier and TypeMethodDescriptionvoidcloseConnection(int shutdownError) Closes the connection with shutdownErrorbooleansendProtocolMessage(List<Header> headers, byte[] payload, MessageType messageType, int messageFlags) Sends a protocol message on the connection.voidsendProtocolMessage(List<Header> headers, byte[] payload, MessageType messageType, int messageFlags, MessageFlushCallback callback) Sends a protocol message on the connection.Methods inherited from class software.amazon.awssdk.crt.CrtResource
addRef, addReferenceTo, close, collectNativeResource, collectNativeResources, decRef, getNativeHandle, getResourceLogDescription, isNull, logNativeResources, logNativeResources, removeReferenceTo, setDescription, waitForNoResources
-
Method Details
-
isConnectionOpen
public boolean isConnectionOpen()- Returns:
- true if the connection is open. False otherwise.
-
closeConnection
public void closeConnection(int shutdownError) Closes the connection with shutdownError- Parameters:
shutdownError- error code to shutdown the connection with. If shutting down cleanly, use 0.
-
sendProtocolMessage
public CompletableFuture<Void> sendProtocolMessage(List<Header> headers, byte[] payload, MessageType messageType, int messageFlags) Sends a protocol message on the connection. Returns a completable future for synchronizing on the message flushing to the underlying transport.- Parameters:
headers- List of event-stream headers. Can be null.payload- Payload to send for the message. Can be null.messageType- Message type for the rpc message.messageFlags- Union of message flags from MessageFlags.getByteValue()- Returns:
- completable future for synchronizing on the message flushing to the underlying transport.
-
sendProtocolMessage
public void sendProtocolMessage(List<Header> headers, byte[] payload, MessageType messageType, int messageFlags, MessageFlushCallback callback) Sends a protocol message on the connection. Returns a completable future for synchronizing on the message flushing to the underlying transport.- Parameters:
headers- List of event-stream headers. Can be null.payload- Payload to send for the message. Can be null.messageType- Message type for the rpc message.messageFlags- Union of message flags from MessageFlags.getByteValue()callback- invoked upon the message flushing to the underlying transport.
-
getClosedFuture
- Returns:
- a future which completes upon the connection closing
-