org.springframework.web.socket.sockjs.transport.session.PollingSockJsSession Java Examples

The following examples show how to use org.springframework.web.socket.sockjs.transport.session.PollingSockJsSession. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SubProtocolWebSocketHandler.java    From spring-analysis-note with MIT License 5 votes vote down vote up
AtomicInteger getCountFor(WebSocketSession session) {
	if (session instanceof PollingSockJsSession) {
		return this.httpPolling;
	}
	else if (session instanceof StreamingSockJsSession) {
		return this.httpStreaming;
	}
	else {
		return this.webSocket;
	}
}
 
Example #2
Source File: SubProtocolWebSocketHandler.java    From java-technology-stack with MIT License 5 votes vote down vote up
private AtomicInteger getCountFor(WebSocketSession session) {
	if (session instanceof PollingSockJsSession) {
		return this.httpPolling;
	}
	else if (session instanceof StreamingSockJsSession) {
		return this.httpStreaming;
	}
	else {
		return this.webSocket;
	}
}
 
Example #3
Source File: SubProtocolWebSocketHandler.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
private AtomicInteger getCountFor(WebSocketSession session) {
	if (session instanceof PollingSockJsSession) {
		return this.httpPolling;
	}
	else if (session instanceof StreamingSockJsSession) {
		return this.httpStreaming;
	}
	else {
		return this.webSocket;
	}
}
 
Example #4
Source File: HttpSendingTransportHandlerTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
private void testJsonpTransport(String callbackValue, boolean expectSuccess) throws Exception {
	JsonpPollingTransportHandler transportHandler = new JsonpPollingTransportHandler();
	transportHandler.initialize(this.sockJsConfig);
	PollingSockJsSession session = transportHandler.createSession("1", this.webSocketHandler, null);

	resetRequestAndResponse();
	setRequest("POST", "/");

	if (callbackValue != null) {
		this.servletRequest.setQueryString("c=" + callbackValue);
		this.servletRequest.addParameter("c", callbackValue);
	}

	try {
		transportHandler.handleRequest(this.request, this.response, this.webSocketHandler, session);
	}
	catch (SockJsTransportFailureException ex) {
		if (expectSuccess) {
			throw new AssertionError("Unexpected transport failure", ex);
		}
	}

	if (expectSuccess) {
		assertEquals(200, this.servletResponse.getStatus());
		assertEquals("application/javascript;charset=UTF-8", this.response.getHeaders().getContentType().toString());
		verify(this.webSocketHandler).afterConnectionEstablished(session);
	}
	else {
		assertEquals(500, this.servletResponse.getStatus());
		verifyNoMoreInteractions(this.webSocketHandler);
	}
}
 
Example #5
Source File: XhrPollingTransportHandler.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
public boolean checkSessionType(SockJsSession session) {
	return session instanceof PollingSockJsSession;
}
 
Example #6
Source File: XhrPollingTransportHandler.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
public PollingSockJsSession createSession(
		String sessionId, WebSocketHandler handler, Map<String, Object> attributes) {

	return new PollingSockJsSession(sessionId, getServiceConfig(), handler, attributes);
}
 
Example #7
Source File: XhrPollingTransportHandler.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
public boolean checkSessionType(SockJsSession session) {
	return session instanceof PollingSockJsSession;
}
 
Example #8
Source File: XhrPollingTransportHandler.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
public PollingSockJsSession createSession(
		String sessionId, WebSocketHandler handler, Map<String, Object> attributes) {

	return new PollingSockJsSession(sessionId, getServiceConfig(), handler, attributes);
}
 
Example #9
Source File: JsonpPollingTransportHandler.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
public PollingSockJsSession createSession(
		String sessionId, WebSocketHandler handler, Map<String, Object> attributes) {

	return new PollingSockJsSession(sessionId, getServiceConfig(), handler, attributes);
}
 
Example #10
Source File: XhrPollingTransportHandler.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
public PollingSockJsSession createSession(
		String sessionId, WebSocketHandler handler, Map<String, Object> attributes) {

	return new PollingSockJsSession(sessionId, getServiceConfig(), handler, attributes);
}