Interface ConnectionErrorHandler
-
public interface ConnectionErrorHandler
Interface for an object that will be notified whenBackgroundEventSource
encounters a network error or receives an error response.This is different from
BackgroundEventHandler.onError(Throwable)
in two ways:- It has the ability to tell BackgroundEventSource to shut down instead of reconnecting.
- If the server simply ends the stream, the
ConnectionErrorHandler
is called with anEOFException
;onError
is not called in this case.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
ConnectionErrorHandler.Action
Return values ofonConnectionError(Throwable)
indicating what action theBackgroundEventSource
should take after an error.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description ConnectionErrorHandler.Action
onConnectionError(java.lang.Throwable t)
This method is called synchronously for all exceptions that occur on the socket connection (including aStreamHttpErrorException
if the server returns an unexpected HTTP status, orEOFException
if the streaming response has ended).
-
-
-
Method Detail
-
onConnectionError
ConnectionErrorHandler.Action onConnectionError(java.lang.Throwable t)
This method is called synchronously for all exceptions that occur on the socket connection (including aStreamHttpErrorException
if the server returns an unexpected HTTP status, orEOFException
if the streaming response has ended).It must not take any direct action to affect the state of the connection, nor do any I/O of its own, but it can return
ConnectionErrorHandler.Action.SHUTDOWN
to cause the connection to close.- Parameters:
t
- aThrowable
object- Returns:
- an
ConnectionErrorHandler.Action
constant
-
-