io.undertow.websockets.core.protocol.version13.Hybi13Handshake Java Examples

The following examples show how to use io.undertow.websockets.core.protocol.version13.Hybi13Handshake. 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: UndertowRequestUpgradeStrategy.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Override
public Mono<Void> upgrade(ServerWebExchange exchange, WebSocketHandler handler,
		@Nullable String subProtocol, Supplier<HandshakeInfo> handshakeInfoFactory) {

	ServerHttpRequest request = exchange.getRequest();
	Assert.isInstanceOf(AbstractServerHttpRequest.class, request);
	HttpServerExchange httpExchange = ((AbstractServerHttpRequest) request).getNativeRequest();

	Set<String> protocols = (subProtocol != null ? Collections.singleton(subProtocol) : Collections.emptySet());
	Hybi13Handshake handshake = new Hybi13Handshake(protocols, false);
	List<Handshake> handshakes = Collections.singletonList(handshake);

	HandshakeInfo handshakeInfo = handshakeInfoFactory.get();
	DataBufferFactory bufferFactory = exchange.getResponse().bufferFactory();

	try {
		DefaultCallback callback = new DefaultCallback(handshakeInfo, handler, bufferFactory);
		new WebSocketProtocolHandshakeHandler(handshakes, callback).handleRequest(httpExchange);
	}
	catch (Exception ex) {
		return Mono.error(ex);
	}

	return Mono.empty();
}
 
Example #2
Source File: UndertowRequestUpgradeStrategy.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Override
public Mono<Void> upgrade(ServerWebExchange exchange, WebSocketHandler handler,
		@Nullable String subProtocol, Supplier<HandshakeInfo> handshakeInfoFactory) {

	ServerHttpRequest request = exchange.getRequest();
	Assert.isInstanceOf(AbstractServerHttpRequest.class, request);
	HttpServerExchange httpExchange = ((AbstractServerHttpRequest) request).getNativeRequest();

	Set<String> protocols = (subProtocol != null ? Collections.singleton(subProtocol) : Collections.emptySet());
	Hybi13Handshake handshake = new Hybi13Handshake(protocols, false);
	List<Handshake> handshakes = Collections.singletonList(handshake);

	HandshakeInfo handshakeInfo = handshakeInfoFactory.get();
	DataBufferFactory bufferFactory = exchange.getResponse().bufferFactory();

	try {
		DefaultCallback callback = new DefaultCallback(handshakeInfo, handler, bufferFactory);
		new WebSocketProtocolHandshakeHandler(handshakes, callback).handleRequest(httpExchange);
	}
	catch (Exception ex) {
		return Mono.error(ex);
	}

	return Mono.empty();
}
 
Example #3
Source File: WebSocketProtocolHandshakeHandler.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create a new {@link WebSocketProtocolHandshakeHandler}
 *
 * @param callback The {@link WebSocketConnectionCallback} which will be executed once the handshake was
 *                 established
 */
public WebSocketProtocolHandshakeHandler(final WebSocketConnectionCallback callback, final HttpHandler next) {
    this.callback = callback;
    Set<Handshake> handshakes = new HashSet<>();
    handshakes.add(new Hybi13Handshake());
    handshakes.add(new Hybi08Handshake());
    handshakes.add(new Hybi07Handshake());
    this.handshakes = handshakes;
    this.next = next;
    this.upgradeListener = null;
}
 
Example #4
Source File: WebSocketProtocolHandshakeHandler.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create a new {@link WebSocketProtocolHandshakeHandler}
 *
 * @param callback The {@link WebSocketConnectionCallback} which will be executed once the handshake was
 *                 established
 */
public WebSocketProtocolHandshakeHandler(final HttpUpgradeListener callback, final HttpHandler next) {
    this.callback = null;
    Set<Handshake> handshakes = new HashSet<>();
    handshakes.add(new Hybi13Handshake());
    handshakes.add(new Hybi08Handshake());
    handshakes.add(new Hybi07Handshake());
    this.handshakes = handshakes;
    this.next = next;
    this.upgradeListener = callback;
}
 
Example #5
Source File: AtmosphereWebSocketUndertowDestination.java    From cxf with Apache License 2.0 5 votes vote down vote up
AtmosphereUndertowWebSocketHandler(UndertowHTTPDestination jhd, boolean cmExact) {
    super(jhd, cmExact);
    handshakes = new HashSet<>();
    handshakes.add(new Hybi13Handshake());
    handshakes.add(new Hybi08Handshake());
    handshakes.add(new Hybi07Handshake());
}
 
Example #6
Source File: UndertowWebSocketDestination.java    From cxf with Apache License 2.0 5 votes vote down vote up
AtmosphereUndertowWebSocketHandler(UndertowHTTPDestination jhd, boolean cmExact) {
    super(jhd, cmExact);
    handshakes = new HashSet<>();
    handshakes.add(new Hybi13Handshake());
    handshakes.add(new Hybi08Handshake());
    handshakes.add(new Hybi07Handshake());
}
 
Example #7
Source File: UndertowWebSocketFilter.java    From pippo with Apache License 2.0 5 votes vote down vote up
@Override
public void init(FilterConfig filterConfig) throws ServletException {
    super.init(filterConfig);

    peerConnections = Collections.newSetFromMap(new ConcurrentHashMap<WebSocketChannel, Boolean>());

    handshakes = new HashSet<>();
    handshakes.add(new Hybi13Handshake());
    handshakes.add(new Hybi08Handshake());
    handshakes.add(new Hybi07Handshake());
}