Class OperationRoutingServerConnectionHandler
- java.lang.Object
-
- software.amazon.awssdk.crt.eventstream.ServerConnectionHandler
-
- software.amazon.awssdk.crt.eventstream.OperationRoutingServerConnectionHandler
-
- All Implemented Interfaces:
AutoCloseable
public class OperationRoutingServerConnectionHandler extends ServerConnectionHandler
ServerConnectionHandler implementation that routes continuations to specific operation specific message handlers
-
-
Field Summary
-
Fields inherited from class software.amazon.awssdk.crt.eventstream.ServerConnectionHandler
connection
-
-
Constructor Summary
Constructors Constructor Description OperationRoutingServerConnectionHandler(ServerConnection serverConnection, Map<String,java.util.function.Function<ServerConnectionContinuation,ServerConnectionContinuationHandler>> operationMapping)
binds an operation handler mapping to a server connection
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
onConnectRequest(List<Header> headers, byte[] payload)
To customize how the connect request is handled, override this function.protected ServerConnectionContinuationHandler
onIncomingStream(ServerConnectionContinuation continuation, String operationName)
When a new stream continuation is received, it routes to the configured operation name to handler mapping.protected void
onProtocolMessage(List<Header> headers, byte[] payload, MessageType messageType, int messageFlags)
By default, automatically responds to pings when received, and routes connect requests.-
Methods inherited from class software.amazon.awssdk.crt.eventstream.ServerConnectionHandler
close, onConnectionClosed
-
-
-
-
Constructor Detail
-
OperationRoutingServerConnectionHandler
public OperationRoutingServerConnectionHandler(ServerConnection serverConnection, Map<String,java.util.function.Function<ServerConnectionContinuation,ServerConnectionContinuationHandler>> operationMapping)
binds an operation handler mapping to a server connection- Parameters:
serverConnection
- connection to route messages foroperationMapping
- mapping of operation names to message handlers.
-
-
Method Detail
-
onProtocolMessage
protected void onProtocolMessage(List<Header> headers, byte[] payload, MessageType messageType, int messageFlags)
By default, automatically responds to pings when received, and routes connect requests. Feel free to override this function if you want different behavior.- Specified by:
onProtocolMessage
in classServerConnectionHandler
- 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
-
onConnectRequest
protected void onConnectRequest(List<Header> headers, byte[] payload)
To customize how the connect request is handled, override this function. You're responsible for sending the response. By default, it accepts all incoming connections.- Parameters:
headers
- list of headers received in the messagepayload
- payload received in the message
-
onIncomingStream
protected final ServerConnectionContinuationHandler onIncomingStream(ServerConnectionContinuation continuation, String operationName)
When a new stream continuation is received, it routes to the configured operation name to handler mapping. If no such mapping exists, an Unsupported Operation message of type ApplicationError is sent to the peer. You can't override this function, because well, if you do, you might as well not use this class in the first place.- Specified by:
onIncomingStream
in classServerConnectionHandler
- Parameters:
continuation
- continuation representing the new incoming streamoperationName
- operation name for the new incoming stream- Returns:
- a new instance of ServerConnectionContinuationHandler for handling continuation events.
-
-