Skip to content

Commit

Permalink
Fixes #1931
Browse files Browse the repository at this point in the history
  • Loading branch information
jfarcand committed Mar 31, 2015
1 parent 23a830b commit 49df0b0
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 4 deletions.
Expand Up @@ -1247,7 +1247,7 @@ public Builder localInetSocketAddress(Callable localAddr) {
}

public Builder attributes(Map<String, Object> attributes) {
localAttributes = Collections.synchronizedMap(attributes);
localAttributes = ConcurrentHashMap.class.isAssignableFrom(attributes.getClass()) ? attributes : Collections.synchronizedMap(attributes);
return this;
}

Expand Down
Expand Up @@ -110,6 +110,10 @@ public interface FrameworkConfig {
* The SimpleHttpProtocol.
*/
String SIMPLE_HTTP_OVER_WEBSOCKET = "polling-websocket-message";
/**
* The SimpleHttpProtocol.
*/
String STREAMING_HTTP_OVER_WEBSOCKET = "streaming-websocket-message";
/**
* Cancel suspending a connection.
*/
Expand Down
Expand Up @@ -18,7 +18,6 @@
import org.atmosphere.cpr.AtmosphereRequest;
import org.atmosphere.cpr.AtmosphereResource;
import org.atmosphere.cpr.AtmosphereResourceImpl;
import org.atmosphere.cpr.FrameworkConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -57,7 +56,6 @@ protected static AtmosphereRequest.Builder constructRequest(AtmosphereResource r

private static Map<String, Object> attributes(AtmosphereRequest request) {
Map<String, Object> m = new ConcurrentHashMap<String, Object>();
m.put(FrameworkConfig.WEBSOCKET_SUBPROTOCOL, FrameworkConfig.SIMPLE_HTTP_OVER_WEBSOCKET);
/***
* This is quite ugly, but the some server may allow null attribute and that break ConcurrentHashMap
*/
Expand Down
Expand Up @@ -19,6 +19,7 @@
import org.atmosphere.cpr.AtmosphereConfig;
import org.atmosphere.cpr.AtmosphereRequest;
import org.atmosphere.cpr.AtmosphereResourceImpl;
import org.atmosphere.cpr.FrameworkConfig;
import org.atmosphere.websocket.WebSocket;
import org.atmosphere.websocket.WebSocketProcessor;
import org.atmosphere.websocket.WebSocketProtocol;
Expand Down Expand Up @@ -88,6 +89,7 @@ public List<AtmosphereRequest> onMessage(WebSocket webSocket, String message) {
return null;
}
AtmosphereRequest request = resource.getRequest(false);
request.setAttribute(FrameworkConfig.WEBSOCKET_SUBPROTOCOL, FrameworkConfig.SIMPLE_HTTP_OVER_WEBSOCKET);

if (!resource.isInScope()) return Collections.emptyList();

Expand Down
Expand Up @@ -19,6 +19,7 @@
import org.atmosphere.cpr.AtmosphereConfig;
import org.atmosphere.cpr.AtmosphereRequest;
import org.atmosphere.cpr.AtmosphereResourceImpl;
import org.atmosphere.cpr.FrameworkConfig;
import org.atmosphere.websocket.WebSocket;
import org.atmosphere.websocket.WebSocketProcessor;
import org.atmosphere.websocket.WebSocketProtocolStream;
Expand Down Expand Up @@ -95,9 +96,10 @@ public List<AtmosphereRequest> onTextStream(WebSocket webSocket, Reader r) {
}

AtmosphereRequest request = resource.getRequest();
request.setAttribute(FrameworkConfig.WEBSOCKET_SUBPROTOCOL, FrameworkConfig.STREAMING_HTTP_OVER_WEBSOCKET);

List<AtmosphereRequest> list = new ArrayList<AtmosphereRequest>();
list.add(constructRequest(resource, request.getPathInfo(), request.getRequestURI(), methodType, contentType.equalsIgnoreCase(TEXT) ? null : contentType, destroyable).reader(r).build());

return list;
}

Expand Down

0 comments on commit 49df0b0

Please sign in to comment.