Skip to content

Commit

Permalink
Fix for #488 each request from the same client returns a different At…
Browse files Browse the repository at this point in the history
…mosphereResource
  • Loading branch information
jfarcand committed Jul 9, 2012
1 parent d8cf515 commit cdce786
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,14 @@ public interface FrameworkConfig {
* A request attribute used to lookup the {@link AtmosphereResource}. This attribute is for framework integrator and not recommend for normal application.
*/
String ATMOSPHERE_RESOURCE = AtmosphereResource.class.getName();
/**
/**
* A request attribute used to lookup the {@link AtmosphereResource} created by an external component and injected inside the {@link AsynchronousProcessor}
*/
String INJECTED_ATMOSPHERE_RESOURCE = AtmosphereResource.class.getName() + ".injected";
/**
* A request attribute used to lookup the {@link AtmosphereResource} created by an external component and injected inside the {@link AsynchronousProcessor}
*/
String WEBSOCKET_ATMOSPHERE_RESOURCE = AtmosphereResource.class.getName() + ".webSocket.handshake";
/**
* Tell a {@link AsyncSupport} it can support session or not
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
import java.util.concurrent.atomic.AtomicReference;

import static org.atmosphere.cpr.FrameworkConfig.ASYNCHRONOUS_HOOK;
import static org.atmosphere.cpr.FrameworkConfig.INJECTED_ATMOSPHERE_RESOURCE;
import static org.atmosphere.cpr.FrameworkConfig.WEBSOCKET_ATMOSPHERE_RESOURCE;

/**
* Like the {@link org.atmosphere.cpr.AsynchronousProcessor} class, this class is responsible for dispatching WebSocket request to the
Expand Down Expand Up @@ -104,12 +106,14 @@ public final void dispatch(final AtmosphereRequest request) throws IOException {
wsr,
framework.getAsyncSupport());

request.setAttribute(FrameworkConfig.INJECTED_ATMOSPHERE_RESOURCE, r);
request.setAttribute(INJECTED_ATMOSPHERE_RESOURCE, r);
request.setAttribute(WEBSOCKET_ATMOSPHERE_RESOURCE, r.uuid());

webSocket.resource(r);
webSocketProtocol.onOpen(webSocket);

dispatch(request, wsr);
request.removeAttribute(FrameworkConfig.INJECTED_ATMOSPHERE_RESOURCE);
request.removeAttribute(INJECTED_ATMOSPHERE_RESOURCE);

if (webSocket.resource() != null) {
final AsynchronousProcessor.AsynchronousProcessorHook hook =
Expand Down

0 comments on commit cdce786

Please sign in to comment.