summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--client/src/com/vaadin/client/ApplicationConnection.java31
-rw-r--r--server/src/com/vaadin/server/communication/ServerRpcHandler.java24
-rw-r--r--server/src/com/vaadin/server/communication/UidlRequestHandler.java4
-rw-r--r--shared/src/com/vaadin/shared/ApplicationConstants.java5
4 files changed, 57 insertions, 7 deletions
diff --git a/client/src/com/vaadin/client/ApplicationConnection.java b/client/src/com/vaadin/client/ApplicationConnection.java
index 3a8d69f25a..64511059d9 100644
--- a/client/src/com/vaadin/client/ApplicationConnection.java
+++ b/client/src/com/vaadin/client/ApplicationConnection.java
@@ -863,7 +863,11 @@ public class ApplicationConnection implements HasHandlers {
+ ApplicationConstants.UIDL_PATH + '/');
if (extraParams != null && extraParams.length() > 0) {
- uri = SharedUtil.addGetParameters(uri, extraParams);
+ if (extraParams.equals(getRepaintAllParameters())) {
+ payload.put(ApplicationConstants.RESYNCHRONIZE_ID, true);
+ } else {
+ uri = SharedUtil.addGetParameters(uri, extraParams);
+ }
}
uri = SharedUtil.addGetParameters(uri, UIConstants.UI_ID_PARAMETER
+ "=" + configuration.getUIId());
@@ -1550,10 +1554,27 @@ public class ApplicationConnection implements HasHandlers {
* e.g. critical server-side notifications
*/
if (syncId != -1) {
- assert (lastSeenServerSyncId == UNDEFINED_SYNC_ID || syncId == lastSeenServerSyncId + 1) : "Newly retrieved server sync id was not exactly one larger than the previous one (new: "
- + syncId + ", last seen: " + lastSeenServerSyncId + ")";
-
- lastSeenServerSyncId = syncId;
+ if (lastSeenServerSyncId == UNDEFINED_SYNC_ID
+ || syncId == (lastSeenServerSyncId + 1)) {
+ lastSeenServerSyncId = syncId;
+ } else {
+ getLogger().warning(
+ "Expected sync id: " + (lastSeenServerSyncId + 1)
+ + ", received: " + syncId
+ + ". Resynchronizing from server.");
+ lastSeenServerSyncId = syncId;
+
+ // Copied from below...
+ ValueMap meta = json.getValueMap("meta");
+ if (meta == null || !meta.containsKey("async")) {
+ // End the request if the received message was a
+ // response, not sent asynchronously
+ endRequest();
+ }
+ resumeResponseHandling(lock);
+ repaintAll();
+ return;
+ }
}
} else {
syncId = -1;
diff --git a/server/src/com/vaadin/server/communication/ServerRpcHandler.java b/server/src/com/vaadin/server/communication/ServerRpcHandler.java
index 450c11f5c4..65fb144810 100644
--- a/server/src/com/vaadin/server/communication/ServerRpcHandler.java
+++ b/server/src/com/vaadin/server/communication/ServerRpcHandler.java
@@ -76,13 +76,14 @@ public class ServerRpcHandler implements Serializable {
private final JsonArray invocations;
private final int syncId;
private final JsonObject json;
+ private final boolean resynchronize;
public RpcRequest(String jsonString, VaadinRequest request) {
json = JsonUtil.parse(jsonString);
JsonValue token = json.get(ApplicationConstants.CSRF_TOKEN);
if (token == null) {
- this.csrfToken = ApplicationConstants.CSRF_TOKEN_DEFAULT_VALUE;
+ csrfToken = ApplicationConstants.CSRF_TOKEN_DEFAULT_VALUE;
} else {
String csrfToken = token.asString();
if (csrfToken.equals("")) {
@@ -98,6 +99,14 @@ public class ServerRpcHandler implements Serializable {
} else {
syncId = -1;
}
+
+ if (json.hasKey(ApplicationConstants.RESYNCHRONIZE_ID)) {
+ resynchronize = json
+ .getBoolean(ApplicationConstants.RESYNCHRONIZE_ID);
+ } else {
+ resynchronize = false;
+ }
+
invocations = json.getArray(ApplicationConstants.RPC_INVOCATIONS);
}
@@ -131,6 +140,15 @@ public class ServerRpcHandler implements Serializable {
}
/**
+ * Checks if this is a request to resynchronize the client side
+ *
+ * @return true if this is a resynchronization request, false otherwise
+ */
+ public boolean isResynchronize() {
+ return resynchronize;
+ }
+
+ /**
* Gets the entire request in JSON format, as it was received from the
* client.
* <p>
@@ -186,6 +204,10 @@ public class ServerRpcHandler implements Serializable {
ui.getConnectorTracker().cleanConcurrentlyRemovedConnectorIds(
rpcRequest.getSyncId());
+
+ if (rpcRequest.isResynchronize()) {
+ ui.getSession().getCommunicationManager().repaintAll(ui);
+ }
}
/**
diff --git a/server/src/com/vaadin/server/communication/UidlRequestHandler.java b/server/src/com/vaadin/server/communication/UidlRequestHandler.java
index 6e338c5773..33a3669b7f 100644
--- a/server/src/com/vaadin/server/communication/UidlRequestHandler.java
+++ b/server/src/com/vaadin/server/communication/UidlRequestHandler.java
@@ -80,10 +80,12 @@ public class UidlRequestHandler extends SynchronizedRequestHandler implements
// repaint requested or session has timed out and new one is created
boolean repaintAll;
- // TODO PUSH repaintAll, analyzeLayouts should be
+ // TODO PUSH analyzeLayouts should be
// part of the message payload to make the functionality transport
// agnostic
+ // Resynchronize is sent in the payload but will still support the
+ // parameter also for compatibility reasons
repaintAll = (request
.getParameter(ApplicationConstants.URL_PARAMETER_REPAINT_ALL) != null);
diff --git a/shared/src/com/vaadin/shared/ApplicationConstants.java b/shared/src/com/vaadin/shared/ApplicationConstants.java
index 37bf5c8a00..3431387b77 100644
--- a/shared/src/com/vaadin/shared/ApplicationConstants.java
+++ b/shared/src/com/vaadin/shared/ApplicationConstants.java
@@ -137,4 +137,9 @@ public class ApplicationConstants implements Serializable {
*/
public static final String CSRF_TOKEN_DEFAULT_VALUE = "init";
+ /**
+ * The name of the parameter used for re-synchronizing.
+ */
+ public static final String RESYNCHRONIZE_ID = "resynchronize";
+
}