]> source.dussan.org Git - vaadin-framework.git/commitdiff
Prepare for Atmosphere Javascript 2.0 (#12241)
authorArtur Signell <artur@vaadin.com>
Thu, 12 Sep 2013 17:57:01 +0000 (20:57 +0300)
committerVaadin Code Review <review@vaadin.com>
Fri, 4 Oct 2013 10:09:44 +0000 (10:09 +0000)
* Atmosphere 2.0 has changed enableProtocol to default to true.
* Reopening a connection in Atmosphere 2.0 is signalled through an onReopen event (not present at all in Atmosphere 1.0.x)

Fix was backported from master

Change-Id: I6ed258087a0b3a06440ab9d19b621560fa4f998f
Merge: no

client/src/com/vaadin/client/communication/AtmospherePushConnection.java

index 3cecb09dc19f5183f8b53e57194967dc4a424991..8bddd78688e6a9914dae34d4b10824930b4fa619 100644 (file)
@@ -228,10 +228,26 @@ public class AtmospherePushConnection implements PushConnection {
         return config;
     }
 
-    protected void onOpen(AtmosphereResponse response) {
-        transport = response.getTransport();
+    protected void onReopen(AtmosphereResponse response) {
+        VConsole.log("Push connection re-established using " + transport);
+        onConnect(response);
+    }
 
+    protected void onOpen(AtmosphereResponse response) {
         VConsole.log("Push connection established using " + transport);
+        onConnect(response);
+    }
+
+    /**
+     * Called whenever a server push connection is established (or
+     * re-established).
+     * 
+     * @param response
+     * 
+     * @since 7.2
+     */
+    protected void onConnect(AtmosphereResponse response) {
+        transport = response.getTransport();
 
         switch (state) {
         case CONNECT_PENDING:
@@ -422,6 +438,7 @@ public class AtmospherePushConnection implements PushConnection {
             reconnectInterval: 5000,
             maxReconnectOnClose: 10000000, 
             trackMessageLength: true,
+            enableProtocol: false,
             messageDelimiter: String.fromCharCode(@com.vaadin.shared.communication.PushConstants::MESSAGE_DELIMITER)
         };
     }-*/;
@@ -435,6 +452,9 @@ public class AtmospherePushConnection implements PushConnection {
         config.onOpen = $entry(function(response) {
             self.@com.vaadin.client.communication.AtmospherePushConnection::onOpen(*)(response);
         });
+        config.onReopen = $entry(function(response) {
+            self.@com.vaadin.client.communication.AtmospherePushConnection::onReopen(*)(response);
+        });
         config.onMessage = $entry(function(response) {
             self.@com.vaadin.client.communication.AtmospherePushConnection::onMessage(*)(response);
         });