diff options
author | Artur Signell <artur@vaadin.com> | 2015-02-24 00:41:15 +0200 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2015-03-02 12:25:06 +0000 |
commit | 251853dce1e79eceae153ff7a374533b1564abde (patch) | |
tree | 172007f5ed6e87ae3efe2c19ce1bef28f1feb514 | |
parent | 2f9ff67c46f09196e3435adb1c6f6e0d3a088e86 (diff) | |
download | vaadin-framework-251853dce1e79eceae153ff7a374533b1564abde.tar.gz vaadin-framework-251853dce1e79eceae153ff7a374533b1564abde.zip |
Disconnect push after application has been stopped (#13248)
Change-Id: I4b8ca76a530453ee95ff88a1a4bbe3fa7a7958d4
-rw-r--r-- | client/src/com/vaadin/client/communication/AtmospherePushConnection.java | 29 |
1 files changed, 21 insertions, 8 deletions
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() { - } - }); - } } /** |