]> 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)
committerArtur Signell <artur@vaadin.com>
Thu, 12 Sep 2013 18:00:54 +0000 (21:00 +0300)
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)

Change-Id: I6013a83a0239b6ab7535631120e442ece2d4481d

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

index 94ea0aaab2be19cd3cda68790301adeb8851284c..93d5d879dce3691832e48a38624f5722172ccc39 100644 (file)
@@ -223,10 +223,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:
@@ -417,6 +433,7 @@ public class AtmospherePushConnection implements PushConnection {
             reconnectInterval: 5000,
             maxReconnectOnClose: 10000000, 
             trackMessageLength: true,
+            enableProtocol: false,
             messageDelimiter: String.fromCharCode(@com.vaadin.shared.communication.PushConstants::MESSAGE_DELIMITER)
         };
     }-*/;
@@ -430,6 +447,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);
         });