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 protected booleancanReleaseReferencesImmediately()Override that determines whether a resource releases its dependencies at the same time the native handle is released or if it waits.voidcloseConnection(int shutdownError)Closes the connection with shutdownErrorCompletableFuture<Integer>getClosedFuture()booleanisConnectionOpen()protected voidreleaseNativeHandle()Required override method that must begin the release process of the acquired native handleCompletableFuture<Void>sendProtocolMessage(List<Header> headers, byte[] payload, MessageType messsageType, int messageFlags)Sends a protocol message on the connection.voidsendProtocolMessage(List<Header> headers, byte[] payload, MessageType messsageType, int messageFlags, MessageFlushCallback callback)Sends a protocol message on the connection.-
Methods inherited from class software.amazon.awssdk.crt.CrtResource
acquireNativeHandle, addRef, addReferenceTo, close, collectNativeResource, collectNativeResources, decRef, getNativeHandle, getResourceLogDescription, isNull, logNativeResources, releaseReferences, removeReferenceTo, setDescription, swapReferenceTo, 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 messsageType, 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.messsageType- 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 messsageType, 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.messsageType- 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
-
releaseNativeHandle
protected void releaseNativeHandle()
Description copied from class:CrtResourceRequired override method that must begin the release process of the acquired native handle- Specified by:
releaseNativeHandlein classCrtResource
-
canReleaseReferencesImmediately
protected boolean canReleaseReferencesImmediately()
Description copied from class:CrtResourceOverride that determines whether a resource releases its dependencies at the same time the native handle is released or if it waits. Resources with asynchronous shutdown processes should override this with false, and establish a callback from native code that invokes releaseReferences() when the asynchronous shutdown process has completed. See HttpClientConnectionManager for an example.- Specified by:
canReleaseReferencesImmediatelyin classCrtResource- Returns:
- true if this resource releases synchronously, false if this resource performs async shutdown
-
-