diff options
author | Artur Signell <artur@vaadin.com> | 2014-03-31 17:22:20 +0300 |
---|---|---|
committer | Artur Signell <artur@vaadin.com> | 2014-04-01 06:52:20 +0000 |
commit | a62f17de3e012751993a6869fef24cd20a1d504f (patch) | |
tree | d048b146c520e5bfff0cf0c0a58a313828716231 /server | |
parent | 58db3494ae4690eb71b94c7744aa53be2fa60110 (diff) | |
download | vaadin-framework-a62f17de3e012751993a6869fef24cd20a1d504f.tar.gz vaadin-framework-a62f17de3e012751993a6869fef24cd20a1d504f.zip |
Use existing AbstractReflectorAtmosphereHandler (#13514)
AbstractReflectorAtmosphereHandler handles cache requests correctly out of the box
Change-Id: I0ab96f53826cf181dc58b007fb6b4ec4eb4ad54d
Diffstat (limited to 'server')
-rw-r--r-- | server/src/com/vaadin/server/communication/PushHandler.java | 49 |
1 files changed, 3 insertions, 46 deletions
diff --git a/server/src/com/vaadin/server/communication/PushHandler.java b/server/src/com/vaadin/server/communication/PushHandler.java index 89e9adb9e6..1557ae9b19 100644 --- a/server/src/com/vaadin/server/communication/PushHandler.java +++ b/server/src/com/vaadin/server/communication/PushHandler.java @@ -18,7 +18,6 @@ package com.vaadin.server.communication; import java.io.IOException; import java.io.Reader; -import java.io.Writer; import java.util.logging.Level; import java.util.logging.Logger; @@ -28,6 +27,7 @@ import org.atmosphere.cpr.AtmosphereResource; import org.atmosphere.cpr.AtmosphereResource.TRANSPORT; import org.atmosphere.cpr.AtmosphereResourceEvent; import org.atmosphere.cpr.AtmosphereResourceEventListenerAdapter; +import org.atmosphere.handler.AbstractReflectorAtmosphereHandler; import org.json.JSONException; import com.vaadin.server.ErrorEvent; @@ -54,54 +54,14 @@ import com.vaadin.ui.UI; */ public class PushHandler extends AtmosphereResourceEventListenerAdapter { - AtmosphereHandler handler = new AtmosphereHandler() { + AtmosphereHandler handler = new AbstractReflectorAtmosphereHandler() { @Override public void onStateChange(AtmosphereResourceEvent event) throws IOException { - AtmosphereResource resource = event.getResource(); - - String id = resource.uuid(); + super.onStateChange(event); if (event.isCancelled() || event.isResumedOnTimeout()) { - getLogger().log(Level.FINER, - "Cancelled connection for resource {0}", id); disconnect(event); - } else if (event.isResuming()) { - // A connection that was suspended earlier was resumed - // (committed to - // the client.) Should only happen if the transport is JSONP or - // long-polling. - getLogger().log(Level.FINER, - "Resuming request for resource {0}", id); - } else { - // A message was broadcast to this resource and should be sent - // to - // the client. We don't do any actual broadcasting, in the sense - // of - // sending to multiple recipients; any UIDL message is specific - // to a - // single client. - getLogger().log(Level.FINER, "Writing message to resource {0}", - id); - - Writer writer = resource.getResponse().getWriter(); - writer.write(event.getMessage().toString()); - - switch (resource.transport()) { - case WEBSOCKET: - break; - case SSE: - case STREAMING: - writer.flush(); - break; - case JSONP: - case LONG_POLLING: - disconnect(event); - break; - default: - getLogger().log(Level.SEVERE, "Unknown transport {0}", - resource.transport()); - } } } @@ -116,9 +76,6 @@ public class PushHandler extends AtmosphereResourceEventListenerAdapter { } } - @Override - public void destroy() { - } }; /** |