use of org.atmosphere.websocket.WebSocket in project atmosphere by Atmosphere.
the class PathTest method testSingletonManagedWebSocketPathMessage.
@Test
public void testSingletonManagedWebSocketPathMessage() throws IOException, ServletException {
instanceCount = 0;
ByteArrayOutputStream b = new ByteArrayOutputStream();
final WebSocket w = new ArrayBaseWebSocket(b);
final WebSocketProcessor processor = WebSocketProcessorFactory.getDefault().getWebSocketProcessor(framework);
AtmosphereRequest request = new AtmosphereRequestImpl.Builder().pathInfo("/singleton/ws/bar").method("GET").build();
processor.open(w, request, AtmosphereResponseImpl.newInstance(framework.getAtmosphereConfig(), request, w));
assertEquals(instanceCount, 0);
assertNotNull(r.get());
assertEquals(MyInterceptor.invokationCount, 1);
assertEquals(r.get(), "/singleton/ws/bar");
}
use of org.atmosphere.websocket.WebSocket in project atmosphere by Atmosphere.
the class EmbeddedWebSocketHandler method webSocket.
private WebSocket webSocket(InputStream inputStream) {
WebSocket webSocket = webSockets.get(inputStream);
if (webSocket == null) {
webSocket = new ArrayBaseWebSocket();
webSockets.put(inputStream, webSocket);
AtmosphereRequest request = AtmosphereRequestImpl.newInstance().header("Connection", "Upgrade").header("Upgrade", "websocket").pathInfo(requestURI);
try {
processor.open(webSocket, request, AtmosphereResponseImpl.newInstance(framework.getAtmosphereConfig(), request, webSocket));
} catch (Exception ex) {
ex.printStackTrace();
}
}
return webSocket;
}
Aggregations