Class ServerConnection
- java.lang.Object
-
- software.amazon.awssdk.crt.CrtResource
-
- software.amazon.awssdk.crt.eventstream.ServerConnection
-
- All Implemented Interfaces:
AutoCloseable
public class ServerConnection extends CrtResource
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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
closeConnection(int shutdownError)
Closes the connection with shutdownErrorCompletableFuture<Integer>
getClosedFuture()
boolean
isConnectionOpen()
CompletableFuture<Void>
sendProtocolMessage(List<Header> headers, byte[] payload, MessageType messageType, int messageFlags)
Sends a protocol message on the connection.void
sendProtocolMessage(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 Detail
-
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
public CompletableFuture<Integer> getClosedFuture()
- Returns:
- a future which completes upon the connection closing
-
-