Class ClientConnectionHandler
- java.lang.Object
-
- software.amazon.awssdk.crt.eventstream.ClientConnectionHandler
-
- All Implemented Interfaces:
AutoCloseable
public abstract class ClientConnectionHandler extends Object implements AutoCloseable
Handler for EventStream ClientConnections. It's marked AutoClosable. By default onConnectionClosed, calls the close() function on this object.
-
-
Field Summary
Fields Modifier and Type Field Description protected ClientConnection
clientConnection
-
Constructor Summary
Constructors Constructor Description ClientConnectionHandler()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
close()
CompletableFuture<Integer>
getConnectionClosedFuture()
protected void
onConnectionClosed(int closeReason)
Invoked upon the connection closed event.protected abstract void
onConnectionSetup(ClientConnection connection, int errorCode)
Invoked upon completion of the Connection attemptprotected abstract void
onProtocolMessage(List<Header> headers, byte[] payload, MessageType messageType, int messageFlags)
Invoked when a message is received on a connection.
-
-
-
Field Detail
-
clientConnection
protected ClientConnection clientConnection
-
-
Method Detail
-
onConnectionSetup
protected abstract void onConnectionSetup(ClientConnection connection, int errorCode)
Invoked upon completion of the Connection attempt- Parameters:
connection
- if the setup was successful, connection is non-null. On error, errorCode will be non-zeroerrorCode
- Error representing any error that occurred during connect.
-
onProtocolMessage
protected abstract void onProtocolMessage(List<Header> headers, byte[] payload, MessageType messageType, int messageFlags)
Invoked when a message is received on a connection.- Parameters:
headers
- List of EventStream headers for the message received.payload
- Payload for the message receivedmessageType
- message type for the messagemessageFlags
- message flags for the message
-
getConnectionClosedFuture
public CompletableFuture<Integer> getConnectionClosedFuture()
- Returns:
- a future for syncing on Connection closed.
-
onConnectionClosed
protected void onConnectionClosed(int closeReason)
Invoked upon the connection closed event. By default it calls close() on this object.- Parameters:
closeReason
- The reason the connection was closed. 0 means a clean shutdown.
-
close
public void close()
- Specified by:
close
in interfaceAutoCloseable
-
-