public static interface ServerSentEvent.Listener
| Modifier and Type | Method and Description |
|---|---|
void |
onClosed(ServerSentEvent sse)
Notify that the connection was closed.
|
void |
onComment(ServerSentEvent sse,
String comment)
Called every time a comment is received.
|
void |
onMessage(ServerSentEvent sse,
String id,
String event,
String message)
Called every time a message is received.
|
void |
onOpen(ServerSentEvent sse,
okhttp3.Response response)
Notify when the connection is open an established.
|
okhttp3.Request |
onPreRetry(ServerSentEvent sse,
okhttp3.Request originalRequest)
Notifies client before retrying to connect.
|
boolean |
onRetryError(ServerSentEvent sse,
Throwable throwable,
okhttp3.Response response)
Notify when the connection failed either because it could not be establish or the connection broke.
|
boolean |
onRetryTime(ServerSentEvent sse,
long milliseconds)
The stream can define the retry time sending a message with "retry: milliseconds"
If this event is received this method will be called with the sent value
|
void onOpen(ServerSentEvent sse, okhttp3.Response response)
sse - the instance of ServerSentEventresponse - the response from the server after establishing the connectionvoid onMessage(ServerSentEvent sse, String id, String event, String message)
sse - the instance of ServerSentEventid - id sent by the server to identify the messageevent - event type of this messagemessage - message payloadvoid onComment(ServerSentEvent sse, String comment)
sse - the instance of ServerSentEventcomment - the content of the commentboolean onRetryTime(ServerSentEvent sse, long milliseconds)
sse - the instance of ServerSentEventmilliseconds - new retry time in millisecondsboolean onRetryError(ServerSentEvent sse, Throwable throwable, okhttp3.Response response)
sse - the instance of ServerSentEventthrowable - the instance of the error that caused the failureresponse - the response of the server that caused the failure, it might be null.void onClosed(ServerSentEvent sse)
sse - the instance of ServerSentEventokhttp3.Request onPreRetry(ServerSentEvent sse, okhttp3.Request originalRequest)
originalRequest to repeat last request or another one to alternatesse - the instance of ServerSentEventoriginalRequest - the request to be retriednull to cancel retry and close the SSE channelCopyright © 2018. All rights reserved.