use of org.springframework.web.socket.sockjs.transport.session.WebSocketServerSockJsSession in project spring-framework by spring-projects.
the class SockJsWebSocketHandlerTests method getSubProtocolsNone.
@Test
public void getSubProtocolsNone() throws Exception {
WebSocketHandler handler = new TextWebSocketHandler();
TaskScheduler scheduler = mock(TaskScheduler.class);
DefaultSockJsService service = new DefaultSockJsService(scheduler);
WebSocketServerSockJsSession session = new WebSocketServerSockJsSession("1", service, handler, null);
SockJsWebSocketHandler sockJsHandler = new SockJsWebSocketHandler(service, handler, session);
assertNull(sockJsHandler.getSubProtocols());
}
use of org.springframework.web.socket.sockjs.transport.session.WebSocketServerSockJsSession in project spring-framework by spring-projects.
the class SockJsWebSocketHandlerTests method getSubProtocols.
@Test
public void getSubProtocols() throws Exception {
SubscribableChannel channel = mock(SubscribableChannel.class);
SubProtocolWebSocketHandler handler = new SubProtocolWebSocketHandler(channel, channel);
StompSubProtocolHandler stompHandler = new StompSubProtocolHandler();
handler.addProtocolHandler(stompHandler);
TaskScheduler scheduler = mock(TaskScheduler.class);
DefaultSockJsService service = new DefaultSockJsService(scheduler);
WebSocketServerSockJsSession session = new WebSocketServerSockJsSession("1", service, handler, null);
SockJsWebSocketHandler sockJsHandler = new SockJsWebSocketHandler(service, handler, session);
assertEquals(stompHandler.getSupportedProtocols(), sockJsHandler.getSubProtocols());
}
use of org.springframework.web.socket.sockjs.transport.session.WebSocketServerSockJsSession in project spring-framework by spring-projects.
the class WebSocketTransportHandler method handleRequest.
@Override
public void handleRequest(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler, SockJsSession wsSession) throws SockJsException {
WebSocketServerSockJsSession sockJsSession = (WebSocketServerSockJsSession) wsSession;
try {
wsHandler = new SockJsWebSocketHandler(getServiceConfig(), wsHandler, sockJsSession);
this.handshakeHandler.doHandshake(request, response, wsHandler, sockJsSession.getAttributes());
} catch (Throwable ex) {
sockJsSession.tryCloseWithSockJsTransportError(ex, CloseStatus.SERVER_ERROR);
throw new SockJsTransportFailureException("WebSocket handshake failure", wsSession.getId(), ex);
}
}
Aggregations