Browse Source

Cherry pick PR #11791 from Vaadin 8 (#11798)

* Cherry pick PR #11791 from Vaadin 8

See: https://github.com/vaadin/framework/pull/11791
tags/7.7.21
Tatu Lund 4 years ago
parent
commit
80146a1a64

+ 16
- 2
client/src/main/java/com/vaadin/client/communication/MessageHandler.java View File

private int lastSeenServerSyncId = UNDEFINED_SYNC_ID; private int lastSeenServerSyncId = UNDEFINED_SYNC_ID;


private ApplicationConnection connection; private ApplicationConnection connection;
private boolean resyncInProgress;


/** /**
* Data structure holding information about pending UIDL messages. * Data structure holding information about pending UIDL messages.
protected void handleJSON(final ValueMap json) { protected void handleJSON(final ValueMap json) {
final int serverId = getServerId(json); final int serverId = getServerId(json);


if (isResynchronize(json) && !isNextExpectedMessage(serverId)) {
boolean hasResynchronize = isResynchronize(json);

if (!hasResynchronize && resyncInProgress) {
Logger.getLogger(MessageHandler.class.getName())
.warning("Dropping the response of a request before a resync request.");
return;
}

resyncInProgress = false;

if (hasResynchronize && !isNextExpectedMessage(serverId)) {
// Resynchronize request. We must remove any old pending // Resynchronize request. We must remove any old pending
// messages and ensure this is handled next. Otherwise we // messages and ensure this is handled next. Otherwise we
// would keep waiting for an older message forever (if this // would keep waiting for an older message forever (if this
int serverNextExpected = json int serverNextExpected = json
.getInt(ApplicationConstants.CLIENT_TO_SERVER_ID); .getInt(ApplicationConstants.CLIENT_TO_SERVER_ID);
getMessageSender().setClientToServerMessageId(serverNextExpected, getMessageSender().setClientToServerMessageId(serverNextExpected,
isResynchronize(json));
hasResynchronize);
} }


if (serverId != -1) { if (serverId != -1) {
} }
}-*/; }-*/;


public void onResynchronize() {
resyncInProgress = true;
}
} }

+ 1
- 0
client/src/main/java/com/vaadin/client/communication/MessageSender.java View File

* state from the server * state from the server
*/ */
public void resynchronize() { public void resynchronize() {
getMessageHandler().onResynchronize();
getLogger().info("Resynchronizing from server"); getLogger().info("Resynchronizing from server");
JsonObject resyncParam = Json.createObject(); JsonObject resyncParam = Json.createObject();
resyncParam.put(ApplicationConstants.RESYNCHRONIZE_ID, true); resyncParam.put(ApplicationConstants.RESYNCHRONIZE_ID, true);

Loading…
Cancel
Save