]> source.dussan.org Git - vaadin-framework.git/commitdiff
Pass AtmosphereResponse to event handler to be able to report real error causes ...
authorArtur Signell <artur@vaadin.com>
Fri, 4 Sep 2015 11:59:15 +0000 (14:59 +0300)
committerArtur Signell <artur@vaadin.com>
Fri, 4 Sep 2015 11:59:15 +0000 (14:59 +0300)
Change-Id: I1117872a4d4b5cbc9a533d0644a40f457be477ca

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

index def2f65e2ae986d7de7954aaf344bd35495ee7d7..8276bf68bb65620cf4826327877ad1d527e2f74f 100644 (file)
@@ -386,17 +386,17 @@ public class AtmospherePushConnection implements PushConnection {
      */
     protected void onError(AtmosphereResponse response) {
         state = State.DISCONNECTED;
-        getConnectionStateHandler().pushError(this);
+        getConnectionStateHandler().pushError(this, response);
     }
 
     protected void onClose(AtmosphereResponse response) {
         state = State.CONNECT_PENDING;
-        getConnectionStateHandler().pushClosed(this);
+        getConnectionStateHandler().pushClosed(this, response);
     }
 
     protected void onClientTimeout(AtmosphereResponse response) {
         state = State.DISCONNECTED;
-        getConnectionStateHandler().pushClientTimeout(this);
+        getConnectionStateHandler().pushClientTimeout(this, response);
     }
 
     protected void onReconnect(JavaScriptObject request,
@@ -575,8 +575,8 @@ public class AtmospherePushConnection implements PushConnection {
 
                         @Override
                         public void onError(ResourceLoadEvent event) {
-                            getConnectionStateHandler()
-                                    .pushScriptLoadError(event.getResourceUrl());
+                            getConnectionStateHandler().pushScriptLoadError(
+                                    event.getResourceUrl());
                         }
                     });
         }
index 4bbca9055ac0c85833288de82958916167fdc9fe..cc33dd0086b6afb4ac83c32e0019c685b953f598 100644 (file)
@@ -15,6 +15,7 @@
  */
 package com.vaadin.client.communication;
 
+import com.google.gwt.core.client.JavaScriptObject;
 import com.google.gwt.http.client.Request;
 import com.google.gwt.http.client.Response;
 import com.vaadin.client.ApplicationConnection;
@@ -76,8 +77,11 @@ public interface ConnectionStateHandler {
      * 
      * @param pushConnection
      *            The push connection which was closed
+     * @param response
+     *            An object containing response data
      */
-    void pushClosed(PushConnection pushConnection);
+    void pushClosed(PushConnection pushConnection,
+            JavaScriptObject responseObject);
 
     /**
      * Called when a client side timeout occurs before a push connection to the
@@ -88,8 +92,11 @@ public interface ConnectionStateHandler {
      * 
      * @param pushConnection
      *            The push connection which timed out
+     * @param response
+     *            An object containing response data
      */
-    void pushClientTimeout(PushConnection pushConnection);
+    void pushClientTimeout(PushConnection pushConnection,
+            JavaScriptObject response);
 
     /**
      * Called when a fatal error fatal error occurs in the push connection.
@@ -102,8 +109,10 @@ public interface ConnectionStateHandler {
      * 
      * @param pushConnection
      *            The push connection where the error occurred
+     * @param response
+     *            An object containing response data
      */
-    void pushError(PushConnection pushConnection);
+    void pushError(PushConnection pushConnection, JavaScriptObject response);
 
     /**
      * Called when the push connection has lost the connection to the server and
index e5c9e317d0f34a4fcefc4230368df695b8308d9b..9d4ea6e1128ee99550ebb85fe55e8b940dff8d5e 100644 (file)
@@ -17,6 +17,7 @@ package com.vaadin.client.communication;
 
 import java.util.logging.Logger;
 
+import com.google.gwt.core.client.JavaScriptObject;
 import com.google.gwt.core.shared.GWT;
 import com.google.gwt.http.client.Request;
 import com.google.gwt.http.client.Response;
@@ -27,6 +28,7 @@ import com.vaadin.client.ApplicationConnection;
 import com.vaadin.client.ApplicationConnection.ApplicationStoppedEvent;
 import com.vaadin.client.ApplicationConnection.ApplicationStoppedHandler;
 import com.vaadin.client.WidgetUtil;
+import com.vaadin.client.communication.AtmospherePushConnection.AtmosphereResponse;
 import com.vaadin.shared.ui.ui.UIState.ReconnectDialogConfigurationState;
 
 import elemental.json.JsonObject;
@@ -562,14 +564,17 @@ public class DefaultConnectionStateHandler implements ConnectionStateHandler {
     }
 
     @Override
-    public void pushError(PushConnection pushConnection) {
+    public void pushError(PushConnection pushConnection,
+            JavaScriptObject response) {
         debug("pushError()");
         connection.handleCommunicationError("Push connection using "
-                + pushConnection.getTransportType() + " failed!", -1);
+                + ((AtmosphereResponse) response).getTransport() + " failed!",
+                -1);
     }
 
     @Override
-    public void pushClientTimeout(PushConnection pushConnection) {
+    public void pushClientTimeout(PushConnection pushConnection,
+            JavaScriptObject response) {
         debug("pushClientTimeout()");
         // TODO Reconnect, allowing client timeout to be set
         // https://dev.vaadin.com/ticket/18429
@@ -580,7 +585,8 @@ public class DefaultConnectionStateHandler implements ConnectionStateHandler {
     }
 
     @Override
-    public void pushClosed(PushConnection pushConnection) {
+    public void pushClosed(PushConnection pushConnection,
+            JavaScriptObject response) {
         debug("pushClosed()");
         getLogger().info("Push connection closed");
     }