Package com.vaadin.client.communication
Interface ConnectionStateHandler
- All Known Implementing Classes:
DefaultConnectionStateHandler
public interface ConnectionStateHandler
Handles problems and other events which occur during communication with the
server.
The handler is responsible for handling any problem in XHR, heartbeat and
push connections in a way it sees fit. The default implementation is
DefaultConnectionStateHandler.- Since:
- 1.0
- Author:
- Vaadin Ltd
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringA string that, if found in a non-JSON response to a UIDL request, will cause the browser to refresh the page. -
Method Summary
Modifier and TypeMethodDescriptionvoidCalled when some part of the reconnect dialog configuration has been changed.voidheartbeatException(com.google.gwt.xhr.client.XMLHttpRequest request, Exception exception) Called when an exception occurs during aHeartbeatrequest.voidheartbeatInvalidStatusCode(com.google.gwt.xhr.client.XMLHttpRequest xhr) Called when a heartbeat request returns a status code other than OK (200).voidCalled when aHeartbeatrequest succeeds.voidpushClientTimeout(PushConnection pushConnection, com.google.gwt.core.client.JavaScriptObject response) Called when a client side timeout occurs before a push connection to the server completes.voidpushClosed(PushConnection pushConnection, com.google.gwt.core.client.JavaScriptObject responseObject) Called when the push connection to the server is closed.voidpushError(PushConnection pushConnection, com.google.gwt.core.client.JavaScriptObject response) Called when a fatal error fatal error occurs in the push connection.voidpushInvalidContent(PushConnection pushConnection, String message) Called when invalid content (not JSON) was pushed from the server through the push connection.voidpushNotConnected(elemental.json.JsonObject payload) Called when a message is to be sent to the server through the push channel but the push channel is not connected.voidpushOk(PushConnection pushConnection) Called when the push connection to the server has been established.voidpushReconnectPending(PushConnection pushConnection) Called when the push connection has lost the connection to the server and will proceed to try to re-establish the connection.voidpushScriptLoadError(String resourceUrl) Called when the required push script could not be loaded.voidxhrException(XhrConnectionError xhrConnectionError) Called when an exception occurs during an XmlHttpRequest request to the server.voidxhrInvalidContent(XhrConnectionError xhrConnectionError) Called when invalid content (not JSON) was returned from the server as the result of an XmlHttpRequest request.voidxhrInvalidStatusCode(XhrConnectionError xhrConnectionError) Called when invalid status code (not 200) was returned by the server as the result of an XmlHttpRequest.voidxhrOk()Called whenever a XmlHttpRequest to the server completes successfully.
-
Field Details
-
UIDL_REFRESH_TOKEN
A string that, if found in a non-JSON response to a UIDL request, will cause the browser to refresh the page. If followed by a colon, optional whitespace, and a URI, causes the browser to synchronously load the URI.This allows, for instance, a servlet filter to redirect the application to a custom login page when the session expires. For example:
if (sessionExpired) { response.setHeader("Content-Type", "text/html"); response.getWriter().write(myLoginPageHtml + "<!-- Vaadin-Refresh: " + request.getContextPath() + " -->"); }- See Also:
-
-
Method Details
-
heartbeatException
Called when an exception occurs during aHeartbeatrequest.- Parameters:
request- The heartbeat requestexception- The exception which occurred
-
heartbeatInvalidStatusCode
void heartbeatInvalidStatusCode(com.google.gwt.xhr.client.XMLHttpRequest xhr) Called when a heartbeat request returns a status code other than OK (200).- Parameters:
xhr- the heartbeat request
-
heartbeatOk
void heartbeatOk()Called when aHeartbeatrequest succeeds. -
pushClosed
void pushClosed(PushConnection pushConnection, com.google.gwt.core.client.JavaScriptObject responseObject) Called when the push connection to the server is closed. This might result in the push connection trying a fallback connection method, trying to reconnect to the server or might just be an indication that the connection was intentionally closed ("unsubscribe"),- Parameters:
pushConnection- The push connection which was closedresponseObject- An object containing response data
-
pushClientTimeout
void pushClientTimeout(PushConnection pushConnection, com.google.gwt.core.client.JavaScriptObject response) Called when a client side timeout occurs before a push connection to the server completes. The client side timeout causes a disconnection of the push connection and no reconnect will be attempted after this method is called,- Parameters:
pushConnection- The push connection which timed outresponse- An object containing response data
-
pushError
Called when a fatal error fatal error occurs in the push connection. The push connection will not try to recover from this situation itself and typically the problem handler should not try to do automatic recovery either. The cause can be e.g. maximum number of reconnection attempts have been reached, neither the selected transport nor the fallback transport can be used or similar.- Parameters:
pushConnection- The push connection where the error occurredresponse- An object containing response data
-
pushReconnectPending
Called when the push connection has lost the connection to the server and will proceed to try to re-establish the connection.- Parameters:
pushConnection- The push connection which will be reconnected
-
pushOk
Called when the push connection to the server has been established.- Parameters:
pushConnection- The push connection which was established
-
pushScriptLoadError
Called when the required push script could not be loaded.- Parameters:
resourceUrl- The URL which was used for loading the script
-
xhrException
Called when an exception occurs during an XmlHttpRequest request to the server.- Parameters:
xhrConnectionError- An event containing what was being sent to the server and what exception occurred
-
xhrInvalidContent
Called when invalid content (not JSON) was returned from the server as the result of an XmlHttpRequest request.- Parameters:
xhrConnectionError- An event containing what was being sent to the server and what was returned
-
xhrInvalidStatusCode
Called when invalid status code (not 200) was returned by the server as the result of an XmlHttpRequest.- Parameters:
xhrConnectionError- An event containing what was being sent to the server and what was returned
-
xhrOk
void xhrOk()Called whenever a XmlHttpRequest to the server completes successfully. -
pushNotConnected
void pushNotConnected(elemental.json.JsonObject payload) Called when a message is to be sent to the server through the push channel but the push channel is not connected.- Parameters:
payload- The payload to send to the server
-
pushInvalidContent
Called when invalid content (not JSON) was pushed from the server through the push connection.- Parameters:
pushConnection- the push connection which was usedmessage- the received message
-
configurationUpdated
void configurationUpdated()Called when some part of the reconnect dialog configuration has been changed.
-