• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java HttpUpgradeListener类的典型用法和代码示例

java 3次浏览

本文整理汇总了Java中io.undertow.server.HttpUpgradeListener的典型用法代码示例。如果您正苦于以下问题:Java HttpUpgradeListener类的具体用法?Java HttpUpgradeListener怎么用?Java HttpUpgradeListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

HttpUpgradeListener类属于io.undertow.server包,在下文中一共展示了HttpUpgradeListener类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: doGet

点赞 2

import io.undertow.server.HttpUpgradeListener; //导入依赖的package包/类
@Override
protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException {

    final ServletWebSocketHttpExchange facade = new ServletWebSocketHttpExchange(req, resp, peerConnections);
    Handshake handshaker = null;
    for (Handshake method : handshakes) {
        if (method.matches(facade)) {
            handshaker = method;
            break;
        }
    }

    if (handshaker == null) {
        UndertowLogger.REQUEST_LOGGER.debug("Could not find hand shaker for web socket request");
        resp.sendError(StatusCodes.BAD_REQUEST);
        return;
    }
    final Handshake selected = handshaker;
    facade.upgradeChannel(new HttpUpgradeListener() {
        @Override
        public void handleUpgrade(StreamConnection streamConnection, HttpServerExchange exchange) {
            WebSocketChannel channel = selected.createChannel(facade, streamConnection, facade.getBufferPool());
            peerConnections.add(channel);
            callback.onConnect(facade, channel);
        }
    });
    handshaker.handshake(facade);
}
 

开发者ID:lamsfoundation,
项目名称:lams,
代码行数:29,
代码来源:WebSocketServlet.java

示例2: WebSocketProtocolHandshakeHandler

点赞 2

import io.undertow.server.HttpUpgradeListener; //导入依赖的package包/类
/**
 * 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;
}
 

开发者ID:lamsfoundation,
项目名称:lams,
代码行数:17,
代码来源:WebSocketProtocolHandshakeHandler.java

示例3: upgradeInternal

点赞 2

import io.undertow.server.HttpUpgradeListener; //导入依赖的package包/类
@Override
protected void upgradeInternal(ServerHttpRequest request, ServerHttpResponse response,
		String selectedProtocol, List<Extension> selectedExtensions, final Endpoint endpoint)
		throws HandshakeFailureException {

	HttpServletRequest servletRequest = getHttpServletRequest(request);
	HttpServletResponse servletResponse = getHttpServletResponse(response);

	final ServletWebSocketHttpExchange exchange = createHttpExchange(servletRequest, servletResponse);
	exchange.putAttachment(HandshakeUtil.PATH_PARAMS, Collections.<String, String>emptyMap());

	ServerWebSocketContainer wsContainer = (ServerWebSocketContainer) getContainer(servletRequest);
	final EndpointSessionHandler endpointSessionHandler = new EndpointSessionHandler(wsContainer);

	final ConfiguredServerEndpoint configuredServerEndpoint = createConfiguredServerEndpoint(
			selectedProtocol, selectedExtensions, endpoint, servletRequest);

	final Handshake handshake = getHandshakeToUse(exchange, configuredServerEndpoint);

	exchange.upgradeChannel(new HttpUpgradeListener() {
		@Override
		public void handleUpgrade(StreamConnection connection, HttpServerExchange serverExchange) {
			Object bufferPool = ReflectionUtils.invokeMethod(getBufferPoolMethod, exchange);
			WebSocketChannel channel = (WebSocketChannel) ReflectionUtils.invokeMethod(
					createChannelMethod, handshake, exchange, connection, bufferPool);
			if (peerConnections != null) {
				peerConnections.add(channel);
			}
			endpointSessionHandler.onConnect(exchange, channel);
		}
	});

	handshake.handshake(exchange);
}
 

开发者ID:langtianya,
项目名称:spring4-understanding,
代码行数:35,
代码来源:UndertowRequestUpgradeStrategy.java

示例4: setUpgradeListener

点赞 2

import io.undertow.server.HttpUpgradeListener; //导入依赖的package包/类
@Override
protected void setUpgradeListener(HttpUpgradeListener upgradeListener) {
    //ignore
}
 

开发者ID:lamsfoundation,
项目名称:lams,
代码行数:5,
代码来源:ServletInitialHandler.java

示例5: upgradeChannel

点赞 2

import io.undertow.server.HttpUpgradeListener; //导入依赖的package包/类
@Override
public void upgradeChannel(final HttpUpgradeListener upgradeCallback) {
    exchange.upgradeChannel(upgradeCallback);
}
 

开发者ID:lamsfoundation,
项目名称:lams,
代码行数:5,
代码来源:ServletWebSocketHttpExchange.java

示例6: getUpgradeListener

点赞 2

import io.undertow.server.HttpUpgradeListener; //导入依赖的package包/类
protected HttpUpgradeListener getUpgradeListener() {
    return upgradeListener;
}
 

开发者ID:lamsfoundation,
项目名称:lams,
代码行数:4,
代码来源:HttpServerConnection.java

示例7: setUpgradeListener

点赞 2

import io.undertow.server.HttpUpgradeListener; //导入依赖的package包/类
@Override
protected void setUpgradeListener(HttpUpgradeListener upgradeListener) {
    this.upgradeListener = upgradeListener;
}
 

开发者ID:lamsfoundation,
项目名称:lams,
代码行数:5,
代码来源:HttpServerConnection.java

示例8: setUpgradeListener

点赞 2

import io.undertow.server.HttpUpgradeListener; //导入依赖的package包/类
@Override
protected void setUpgradeListener(HttpUpgradeListener upgradeListener) {
    throw UndertowMessages.MESSAGES.upgradeNotSupported();
}
 

开发者ID:lamsfoundation,
项目名称:lams,
代码行数:5,
代码来源:SpdyServerConnection.java

示例9: setConnectListener

点赞 2

import io.undertow.server.HttpUpgradeListener; //导入依赖的package包/类
@Override
protected void setConnectListener(HttpUpgradeListener connectListener) {
    //ignore
}
 

开发者ID:wildfly-swarm,
项目名称:wildfly-swarm,
代码行数:5,
代码来源:InVMConnection.java

示例10: setConnectListener

点赞 2

import io.undertow.server.HttpUpgradeListener; //导入依赖的package包/类
@Override
protected void setConnectListener(HttpUpgradeListener connectListener) {
}
 

开发者ID:arquillian,
项目名称:arquillian-cube,
代码行数:4,
代码来源:PortForwardServerConnection.java

示例11: upgradeChannel

点赞 1

import io.undertow.server.HttpUpgradeListener; //导入依赖的package包/类
/**
 * Upgrade the underlying channel
 *
 * @param upgradeCallback
 */
void upgradeChannel(final HttpUpgradeListener upgradeCallback);
 

开发者ID:lamsfoundation,
项目名称:lams,
代码行数:7,
代码来源:WebSocketHttpExchange.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)