Skip to content

Retrieving the original AtmosphereResource with WebSocket

jfarcand edited this page Oct 16, 2012 · 5 revisions

This content has been merged into Understanding AtmosphereResource

To support WebSocket the same way as other transport, Atmosphere, by default, creates an AtmosphereResource for the handshake operation, and new AtmosphereResource every time a new websocket message is received. In case your application needs to retrieve the original one, e.g the one used for the handshake, just using the following attribute from any AtmosphereRequest:

   String uuid = (String) request
        .getAttribute(ApplicationConfig.SUSPENDED_ATMOSPHERE_RESOURCE_UUID);
   AtmosphereResource resource = AtmosphereResourceFactory
         .getDefault().find(uuid);
Clone this wiki locally