From: Artur Signell Date: Mon, 23 Feb 2015 22:41:15 +0000 (+0200) Subject: Disconnect push after application has been stopped (#13248) X-Git-Tag: 7.5.0.alpha1~59 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=251853dce1e79eceae153ff7a374533b1564abde;p=vaadin-framework.git Disconnect push after application has been stopped (#13248) Change-Id: I4b8ca76a530453ee95ff88a1a4bbe3fa7a7958d4 --- diff --git a/client/src/com/vaadin/client/communication/AtmospherePushConnection.java b/client/src/com/vaadin/client/communication/AtmospherePushConnection.java index a3a8caa1b4..787da9bc6f 100644 --- a/client/src/com/vaadin/client/communication/AtmospherePushConnection.java +++ b/client/src/com/vaadin/client/communication/AtmospherePushConnection.java @@ -24,6 +24,8 @@ import com.google.gwt.user.client.Command; import com.google.gwt.user.client.Window.Location; import com.vaadin.client.ApplicationConfiguration; import com.vaadin.client.ApplicationConnection; +import com.vaadin.client.ApplicationConnection.ApplicationStoppedEvent; +import com.vaadin.client.ApplicationConnection.ApplicationStoppedHandler; import com.vaadin.client.ApplicationConnection.CommunicationErrorHandler; import com.vaadin.client.ResourceLoader; import com.vaadin.client.ResourceLoader.ResourceLoadEvent; @@ -152,6 +154,25 @@ public class AtmospherePushConnection implements PushConnection { this.connection = connection; this.errorHandler = errorHandler; + connection.addHandler(ApplicationStoppedEvent.TYPE, + new ApplicationStoppedHandler() { + + @Override + public void onApplicationStopped( + ApplicationStoppedEvent event) { + if (state == State.DISCONNECT_PENDING + || state == State.DISCONNECTED) { + return; + } + + disconnect(new Command() { + @Override + public void execute() { + } + }); + + } + }); config = createConfig(); String debugParameter = Location.getParameter("debug"); if ("push".equals(debugParameter)) { @@ -324,14 +345,6 @@ public class AtmospherePushConnection implements PushConnection { message = message.substring(9, message.length() - 1); connection.handlePushMessage(message); } - - if (!connection.isApplicationRunning()) { - disconnect(new Command() { - @Override - public void execute() { - } - }); - } } /**