|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.vaadin.client.communication.DefaultConnectionStateHandler
public class DefaultConnectionStateHandler
Default implementation of the connection state handler.
Handles temporary errors by showing a reconnect dialog to the user while trying to re-establish the connection to the server and re-send the pending message.
Handles permanent errors by showing a critical system notification to the user
| Nested Class Summary | |
|---|---|
protected static class |
DefaultConnectionStateHandler.Type
|
| Constructor Summary | |
|---|---|
DefaultConnectionStateHandler()
|
|
| Method Summary | |
|---|---|
void |
configurationUpdated()
Called when some part of the reconnect dialog configuration has been changed. |
protected void |
doReconnect(elemental.json.JsonObject payload)
Re-sends the payload to the server (if not null) or re-sends a heartbeat request immediately |
protected ApplicationConnection |
getConnection()
Returns the connection this handler is connected to |
protected java.lang.String |
getDialogText(int reconnectAttempt)
Gets the text to show in the reconnect dialog |
protected java.lang.String |
getDialogTextGaveUp(int reconnectAttempt)
Gets the text to show in the reconnect dialog after giving up (reconnect limit reached) |
protected void |
giveUp()
Called when we should give up trying to reconnect and let the user decide how to continue |
protected void |
handleRecoverableError(DefaultConnectionStateHandler.Type type,
elemental.json.JsonObject payload)
Called whenever an error occurs in communication which should be handled by showing the reconnect dialog and retrying communication until successful again |
protected void |
handleUnauthorized(XhrConnectionError xhrConnectionError)
|
void |
heartbeatException(Request request,
java.lang.Throwable exception)
Called when an exception occurs during a Heartbeat request |
void |
heartbeatInvalidStatusCode(Request request,
Response response)
Called when a heartbeat request returns a status code other than OK (200) |
void |
heartbeatOk()
Called when a Heartbeat request succeeds |
protected void |
hideDialog()
Called when the reconnect dialog should be hidden. |
protected boolean |
isDialogVisible()
Checks if the reconnect dialog is visible to the user |
void |
pushClientTimeout(PushConnection pushConnection,
JavaScriptObject response)
Called when a client side timeout occurs before a push connection to the server completes. |
void |
pushClosed(PushConnection pushConnection,
JavaScriptObject response)
Called when the push connection to the server is closed. |
void |
pushError(PushConnection pushConnection,
JavaScriptObject response)
Called when a fatal error fatal error occurs in the push connection. |
void |
pushInvalidContent(PushConnection pushConnection,
java.lang.String message)
Called when invalid content (not JSON) was pushed from the server through the push connection |
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 |
void |
pushOk(PushConnection pushConnection)
Called when the push connection to the server has been established. |
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 |
void |
pushScriptLoadError(java.lang.String resourceUrl)
Called when the required push script could not be loaded |
protected void |
scheduleReconnect(elemental.json.JsonObject payload)
Called after a problem occurred. |
void |
setConnection(ApplicationConnection connection)
Sets the application connection this instance is connected to. |
protected void |
showDialog()
Called when the reconnect dialog should be shown. |
protected void |
updateDialog()
Called whenever a reconnect attempt fails to allow updating of dialog contents |
void |
xhrException(XhrConnectionError xhrConnectionError)
Called when an exception occurs during an XmlHttpRequest request to the server. |
void |
xhrInvalidContent(XhrConnectionError xhrConnectionError)
Called when invalid content (not JSON) was returned from the server as the result of an XmlHttpRequest request |
void |
xhrInvalidStatusCode(XhrConnectionError xhrConnectionError)
Called when invalid status code (not 200) was returned by the server as the result of an XmlHttpRequest. |
void |
xhrOk()
Called whenever a XmlHttpRequest to the server completes successfully |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public DefaultConnectionStateHandler()
| Method Detail |
|---|
public void setConnection(ApplicationConnection connection)
ConnectionStateHandler
setConnection in interface ConnectionStateHandlerconnection - the application connection this instance is connected toprotected ApplicationConnection getConnection()
public void xhrException(XhrConnectionError xhrConnectionError)
ConnectionStateHandler
xhrException in interface ConnectionStateHandlerxhrConnectionError - An event containing what was being sent to the server and what
exception occurred
public void heartbeatException(Request request,
java.lang.Throwable exception)
ConnectionStateHandlerHeartbeat request
heartbeatException in interface ConnectionStateHandlerrequest - The heartbeat requestexception - The exception which occurred
public void heartbeatInvalidStatusCode(Request request,
Response response)
ConnectionStateHandler
heartbeatInvalidStatusCode in interface ConnectionStateHandlerrequest - The heartbeat requestresponse - The heartbeat responsepublic void heartbeatOk()
ConnectionStateHandlerHeartbeat request succeeds
heartbeatOk in interface ConnectionStateHandler
protected void handleRecoverableError(DefaultConnectionStateHandler.Type type,
elemental.json.JsonObject payload)
type - The type of failure detectedpayload - The message which did not reach the server, or null if no
message was involved (heartbeat or push connection failed)protected void scheduleReconnect(elemental.json.JsonObject payload)
payload - the payload that did not reach the server, null if the problem
was detected by a heartbeatprotected void doReconnect(elemental.json.JsonObject payload)
payload - the payload that did not reach the server, null if the problem
was detected by a heartbeatprotected void updateDialog()
protected void giveUp()
protected boolean isDialogVisible()
protected void showDialog()
protected void hideDialog()
protected java.lang.String getDialogTextGaveUp(int reconnectAttempt)
reconnectAttempt - The number of the current reconnection attempt
protected java.lang.String getDialogText(int reconnectAttempt)
reconnectAttempt - The number of the current reconnection attempt
public void configurationUpdated()
ConnectionStateHandler
configurationUpdated in interface ConnectionStateHandlerpublic void xhrInvalidContent(XhrConnectionError xhrConnectionError)
ConnectionStateHandler
xhrInvalidContent in interface ConnectionStateHandler
public void pushInvalidContent(PushConnection pushConnection,
java.lang.String message)
ConnectionStateHandler
pushInvalidContent in interface ConnectionStateHandlerpublic void xhrInvalidStatusCode(XhrConnectionError xhrConnectionError)
ConnectionStateHandler
xhrInvalidStatusCode in interface ConnectionStateHandlerprotected void handleUnauthorized(XhrConnectionError xhrConnectionError)
public void xhrOk()
ConnectionStateHandler
xhrOk in interface ConnectionStateHandlerpublic void pushOk(PushConnection pushConnection)
ConnectionStateHandler
pushOk in interface ConnectionStateHandlerpushConnection - The push connection which was establishedpublic void pushScriptLoadError(java.lang.String resourceUrl)
ConnectionStateHandler
pushScriptLoadError in interface ConnectionStateHandlerresourceUrl - The URL which was used for loading the scriptpublic void pushNotConnected(elemental.json.JsonObject payload)
ConnectionStateHandler
pushNotConnected in interface ConnectionStateHandlerpayload - The payload to send to the serverpublic void pushReconnectPending(PushConnection pushConnection)
ConnectionStateHandler
pushReconnectPending in interface ConnectionStateHandlerpushConnection - The push connection which will be reconnected
public void pushError(PushConnection pushConnection,
JavaScriptObject response)
ConnectionStateHandler
pushError in interface ConnectionStateHandlerpushConnection - The push connection where the error occurredresponse - An object containing response data
public void pushClientTimeout(PushConnection pushConnection,
JavaScriptObject response)
ConnectionStateHandler
pushClientTimeout in interface ConnectionStateHandlerpushConnection - The push connection which timed outresponse - An object containing response data
public void pushClosed(PushConnection pushConnection,
JavaScriptObject response)
ConnectionStateHandler
pushClosed in interface ConnectionStateHandlerpushConnection - The push connection which was closed
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||