Package com.vaadin.client.communication
Interface ConnectionStateHandler
-
- All Known Implementing Classes:
DefaultConnectionStateHandler
public interface ConnectionStateHandlerHandles 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 isDefaultConnectionStateHandler.- Since:
- 1.0
- Author:
- Vaadin Ltd
-
-
Field Summary
Fields Modifier and Type Field Description static StringUIDL_REFRESH_TOKENA string that, if found in a non-JSON response to a UIDL request, will cause the browser to refresh the page.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidconfigurationUpdated()Called 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).voidheartbeatOk()Called 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 Detail
-
UIDL_REFRESH_TOKEN
static final String 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:
- Constant Field Values
-
-
Method Detail
-
heartbeatException
void heartbeatException(com.google.gwt.xhr.client.XMLHttpRequest request, Exception exception)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
void pushError(PushConnection pushConnection, com.google.gwt.core.client.JavaScriptObject response)
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
void pushReconnectPending(PushConnection pushConnection)
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
void pushOk(PushConnection pushConnection)
Called when the push connection to the server has been established.- Parameters:
pushConnection- The push connection which was established
-
pushScriptLoadError
void pushScriptLoadError(String resourceUrl)
Called when the required push script could not be loaded.- Parameters:
resourceUrl- The URL which was used for loading the script
-
xhrException
void xhrException(XhrConnectionError xhrConnectionError)
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
void xhrInvalidContent(XhrConnectionError xhrConnectionError)
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
void xhrInvalidStatusCode(XhrConnectionError xhrConnectionError)
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
void pushInvalidContent(PushConnection pushConnection, String message)
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.
-
-