summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorAleksi Hietanen <aleksi@vaadin.com>2017-04-13 11:48:49 +0300
committerTeemu Suo-Anttila <tsuoanttila@users.noreply.github.com>2017-05-08 14:46:35 +0300
commit47f44682e05e9526949bae549800592f82ac1ae7 (patch)
tree9002d9d34f4ac2f3e2f95e2884cb4c7a64b9877a /client
parent8f1b372a72700c50e4e4a1d7835099087467aeeb (diff)
downloadvaadin-framework-47f44682e05e9526949bae549800592f82ac1ae7.tar.gz
vaadin-framework-47f44682e05e9526949bae549800592f82ac1ae7.zip
Use separate identifier for push connections
Closes #8700
Diffstat (limited to 'client')
-rw-r--r--client/src/main/java/com/vaadin/client/communication/AtmospherePushConnection.java12
-rw-r--r--client/src/main/java/com/vaadin/client/communication/MessageHandler.java19
2 files changed, 25 insertions, 6 deletions
diff --git a/client/src/main/java/com/vaadin/client/communication/AtmospherePushConnection.java b/client/src/main/java/com/vaadin/client/communication/AtmospherePushConnection.java
index ba7fa39a7d..511a37b7e6 100644
--- a/client/src/main/java/com/vaadin/client/communication/AtmospherePushConnection.java
+++ b/client/src/main/java/com/vaadin/client/communication/AtmospherePushConnection.java
@@ -207,10 +207,10 @@ public class AtmospherePushConnection implements PushConnection {
String extraParams = UIConstants.UI_ID_PARAMETER + "="
+ connection.getConfiguration().getUIId();
- String csrfToken = connection.getMessageHandler().getCsrfToken();
- if (!csrfToken.equals(ApplicationConstants.CSRF_TOKEN_DEFAULT_VALUE)) {
- extraParams += "&" + ApplicationConstants.CSRF_TOKEN_PARAMETER + "="
- + csrfToken;
+ String pushId = connection.getMessageHandler().getPushId();
+ if (pushId != null) {
+ extraParams += "&" + ApplicationConstants.PUSH_ID_PARAMETER + "="
+ + pushId;
}
// uri is needed to identify the right connection when closing
@@ -526,7 +526,7 @@ public class AtmospherePushConnection implements PushConnection {
JavaScriptObject config)
/*-{
var self = this;
-
+
config.url = uri;
config.onOpen = $entry(function(response) {
self.@com.vaadin.client.communication.AtmospherePushConnection::onOpen(*)(response);
@@ -552,7 +552,7 @@ public class AtmospherePushConnection implements PushConnection {
config.onClientTimeout = $entry(function(request) {
self.@com.vaadin.client.communication.AtmospherePushConnection::onClientTimeout(*)(request);
});
-
+
return $wnd.vaadinPush.atmosphere.subscribe(config);
}-*/;
diff --git a/client/src/main/java/com/vaadin/client/communication/MessageHandler.java b/client/src/main/java/com/vaadin/client/communication/MessageHandler.java
index dcc3810a2d..c9cbf5737f 100644
--- a/client/src/main/java/com/vaadin/client/communication/MessageHandler.java
+++ b/client/src/main/java/com/vaadin/client/communication/MessageHandler.java
@@ -134,6 +134,9 @@ public class MessageHandler {
// will hold the CSRF token once received
private String csrfToken = ApplicationConstants.CSRF_TOKEN_DEFAULT_VALUE;
+ // holds the push identifier once received
+ private String pushId = null;
+
/** Timer for automatic redirect to SessionExpiredURL */
private Timer redirectTimer;
@@ -350,6 +353,12 @@ public class MessageHandler {
csrfToken = json
.getString(ApplicationConstants.UIDL_SECURITY_TOKEN_ID);
}
+
+ // Get push id if present
+ if (json.containsKey(ApplicationConstants.UIDL_PUSH_ID)) {
+ pushId = json.getString(ApplicationConstants.UIDL_PUSH_ID);
+ }
+
getLogger().info(" * Handling resources from server");
if (json.containsKey("resources")) {
@@ -1688,6 +1697,16 @@ public class MessageHandler {
}
/**
+ * Gets the push connection identifier for this session. Used when
+ * establishing a push connection with the client.
+ *
+ * @return the push connection identifier string
+ */
+ public String getPushId() {
+ return pushId;
+ }
+
+ /**
* Checks whether state changes are currently being processed. Certain
* operations are not allowed when the internal state of the application
* might be in an inconsistent state because some state changes have been