public class MessageHandler extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
JSON_COMMUNICATION_PREFIX |
static String |
JSON_COMMUNICATION_SUFFIX |
protected int |
lastProcessingTime
Holds the time spent rendering the last request.
|
protected int |
totalProcessingTime
Holds the total time spent rendering requests during the lifetime of the
session.
|
| Constructor and Description |
|---|
MessageHandler(Registry registry)
Creates a new instance connected to the given registry.
|
| Modifier and Type | Method and Description |
|---|---|
String |
getCsrfToken()
Gets the token (aka double submit cookie) that the server uses to protect
against Cross Site Request Forgery attacks.
|
int |
getLastSeenServerSyncId()
Gets the server id included in the last received response.
|
String |
getPushId()
Gets the push connection identifier for this session.
|
protected void |
handleJSON(ValueMap valueMap) |
void |
handleMessage(ValueMap json)
Handles a received UIDL JSON text, parsing it, and passing it on to the
appropriate handlers, while logging timing information.
|
boolean |
isInitialUidlHandled()
Checks if the first UIDL has been handled.
|
static ValueMap |
parseJson(String jsonText)
Unwraps and parses the given JSON, originating from the server.
|
static ValueMap |
parseWrappedJson(String wrappedJsonText)
Parse the given wrapped JSON, received from the server, to a ValueMap.
|
void |
resumeResponseHandling(Object lock)
Resumes the rendering process once all locks have been removed.
|
void |
setNextResponseSessionExpiredHandler(Command nextResponseSessionExpiredHandler)
Sets a temporary handler for session expiration.
|
static String |
stripJSONWrapping(String jsonWithWrapping)
Strips the JSON wrapping from the given json string with wrapping.
|
void |
suspendReponseHandling(Object lock)
This method can be used to postpone rendering of a response for a short
period of time (e.g.
|
public static final String JSON_COMMUNICATION_PREFIX
public static final String JSON_COMMUNICATION_SUFFIX
protected int lastProcessingTime
protected int totalProcessingTime
public MessageHandler(Registry registry)
registry - the global registrypublic void handleMessage(ValueMap json)
json - The JSON to handleprotected void handleJSON(ValueMap valueMap)
public void suspendReponseHandling(Object lock)
lock - the lockpublic void resumeResponseHandling(Object lock)
lock - the lockpublic int getLastSeenServerSyncId()
This id can be used by connectors to determine whether new data has been received from the server to avoid doing the same calculations multiple times.
No guarantees are made for the structure of the id other than that there will be a new unique value every time a new response with data from the server is received.
The initial id when no request has yet been processed is -1.
public String getCsrfToken()
public String getPushId()
public boolean isInitialUidlHandled()
public static String stripJSONWrapping(String jsonWithWrapping)
jsonWithWrapping - the JSON received from the serverpublic static ValueMap parseJson(String jsonText)
jsonText - the json from the serverpublic static ValueMap parseWrappedJson(String wrappedJsonText)
wrappedJsonText - the json, wrapped as done by the serverpublic void setNextResponseSessionExpiredHandler(Command nextResponseSessionExpiredHandler)
nextResponseSessionExpiredHandler - the handler to use or null to remove a previously set handlerCopyright © 2000–2018 Vaadin Ltd. All rights reserved.