summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2015-02-24 00:41:15 +0200
committerArtur Signell <artur@vaadin.com>2015-03-02 21:51:33 +0200
commitf2ef782b50da96308bc6f4cca41320691bcb8b05 (patch)
tree0dda533172a0d182264d21cc58f253b617e902de
parent5cd321f2d3eaed177d1453a4c27f93adf606f89a (diff)
downloadvaadin-framework-f2ef782b50da96308bc6f4cca41320691bcb8b05.tar.gz
vaadin-framework-f2ef782b50da96308bc6f4cca41320691bcb8b05.zip
Disconnect push after application has been stopped (#13248)
Change-Id: I4b8ca76a530453ee95ff88a1a4bbe3fa7a7958d4
-rw-r--r--client/src/com/vaadin/client/communication/AtmospherePushConnection.java29
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 da08928f36..e544c91d0f 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;
@@ -150,6 +152,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)) {
@@ -319,14 +340,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() {
- }
- });
- }
}
/**