From 633b4e858c31769f4b8848c934651da1d54b2721 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Thu, 12 Sep 2013 20:57:01 +0300 Subject: Prepare for Atmosphere Javascript 2.0 (#12241) * 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 --- .../communication/AtmospherePushConnection.java | 24 ++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'client') diff --git a/client/src/com/vaadin/client/communication/AtmospherePushConnection.java b/client/src/com/vaadin/client/communication/AtmospherePushConnection.java index 3cecb09dc1..8bddd78688 100644 --- a/client/src/com/vaadin/client/communication/AtmospherePushConnection.java +++ b/client/src/com/vaadin/client/communication/AtmospherePushConnection.java @@ -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); }); -- cgit v1.2.3