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().
  • 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

      public CompletableFuture<Integer> getClosedFuture()
      Returns:
      a future which completes upon the connection closing