Interface EventStreamRPCConnection.LifecycleHandler
- Enclosing class:
- EventStreamRPCConnection
public static interface EventStreamRPCConnection.LifecycleHandler
Lifecycle handler is how a client can react and respond to connectivity interruptions. Connectivity
interruptions are isolated from operation availability issues.
-
Method Summary
Modifier and TypeMethodDescriptionvoidInvoked only if there is a successful connection.voidonDisconnect(int errorCode) Invoked for both connect failures and disconnects from a healthy statebooleanUsed to communicate errors that occur on the connection during any phase of its lifecycle that may not appropriately or easily attach to onConnect() or onDisconnect().default voidDo nothing on ping by default.
-
Method Details
-
onConnect
void onConnect()Invoked only if there is a successful connection. Leaves out the error code since it will have already been compared to AWS_OP_SUCCESS -
onDisconnect
void onDisconnect(int errorCode) Invoked for both connect failures and disconnects from a healthy state- Parameters:
errorCode- A code indicating the reason for the disconnect
-
onError
Used to communicate errors that occur on the connection during any phase of its lifecycle that may not appropriately or easily attach to onConnect() or onDisconnect(). Return value of this indicates whether or not the client should stay connected or terminate the connection. Returning true indicates the connection should terminate as a result of the error, and false indicates that the connection should not. If the handler throws, is the same as returning true. Note: Some conditions when onError() is called will not care about the return value and always result in closing the connection. AccessDeniedException is such an example- Parameters:
t- Exception- Returns:
- true if the connection should be terminated as a result of handling the error
-
onPing
Do nothing on ping by default. Inform handler of ping data TODO: Could use boolean return here as a hint on whether a pong reply should be sent?- Parameters:
headers- The ping headerspayload- The ping payload
-