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 boolean
canReleaseReferencesImmediately()
Override that determines whether a resource releases its dependencies at the same time the native handle is released or if it waits.void
closeConnection(int shutdownError)
Closes the connection with shutdownErrorCompletableFuture<Integer>
getClosedFuture()
boolean
isConnectionOpen()
protected void
releaseNativeHandle()
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.void
sendProtocolMessage(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:CrtResource
Required override method that must begin the release process of the acquired native handle- Specified by:
releaseNativeHandle
in classCrtResource
-
canReleaseReferencesImmediately
protected boolean canReleaseReferencesImmediately()
Description copied from class:CrtResource
Override 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:
canReleaseReferencesImmediately
in classCrtResource
- Returns:
- true if this resource releases synchronously, false if this resource performs async shutdown
-
-