当前位置: 首页>>代码示例>>Java>>正文


Java ServerWebSocket类代码示例

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


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

示例1: handle

import org.vertx.java.core.http.ServerWebSocket; //导入依赖的package包/类
@Override
public void handle(final ServerWebSocket socket) {
    DetectingGateway handler = this.gateway.get();
    if ( handler==null ) {
        LOG.info("Rejecting web socket: no protocol detecting gateway deployed");
        socket.reject();
        return;
    } else if ( pathPrefix!=null && !socket.path().startsWith(pathPrefix) ) {
        LOG.info("Rejecting web socket: request path does not start with:"+ pathPrefix);
        socket.reject();
        return;
    }
    LOG.info("Processing the web socket '"+socket.remoteAddress()+"' with the protocol detecting gateway");
    handler.handle(SocketWrapper.wrap(socket));
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:16,代码来源:DetectingGatewayWebSocketHandler.java

示例2: start

import org.vertx.java.core.http.ServerWebSocket; //导入依赖的package包/类
public void start(int port) {

        vertx = VertxFactory.newVertx();

        httpServer = vertx.createHttpServer();
        httpServer.websocketHandler(new Handler<ServerWebSocket>() {
            public void handle(final ServerWebSocket ws) {

                if (ws.path().equals("/echo")) {

                    ws.frameHandler(new Handler<WebSocketFrame>() {
                        @Override
                        public void handle(WebSocketFrame webSocketFrame) {
                            if (webSocketFrame.isBinary()) {
                                Buffer buff = new Buffer(((WebSocketFrameInternal) webSocketFrame).getBinaryData());
                                ws.writeBinaryFrame(buff);
                            } else if (webSocketFrame.isText()) {
                                ws.writeTextFrame(webSocketFrame.textData());
                            }
                        }
                    });

                } else {
                    ws.reject();
                }
            }
        }).listen(port);
    }
 
开发者ID:matzew,项目名称:simple-websocket-client,代码行数:29,代码来源:WebSocketServer.java

示例3: getSigned

import org.vertx.java.core.http.ServerWebSocket; //导入依赖的package包/类
public String getSigned(String name, String path, ServerWebSocket ws) {
	if (ws.headers().get("Cookie") != null) {
		Set<Cookie> cookies = CookieDecoder.decode(ws.headers().get("Cookie"));
		return getSignedCookie(name, path, cookies);
	}
	return null;
}
 
开发者ID:web-education,项目名称:web-utils,代码行数:8,代码来源:CookieHelper.java

示例4: HttpGatewayServer

import org.vertx.java.core.http.ServerWebSocket; //导入依赖的package包/类
public HttpGatewayServer(Vertx vertx, HttpGatewayHandler handler, Handler<ServerWebSocket> websocketHandler, int port) {
    this.vertx = vertx;
    this.handler = handler;
    this.websocketHandler = websocketHandler;
    this.port = port;
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:7,代码来源:HttpGatewayServer.java

示例5: addWebSocket

import org.vertx.java.core.http.ServerWebSocket; //导入依赖的package包/类
public void addWebSocket(ServerWebSocket webSocket) {
    if(!webSockets.contains(webSocket))webSockets.add(webSocket);
}
 
开发者ID:amoAHCP,项目名称:vert.x-spring-microservice-demo,代码行数:4,代码来源:WebSocketRepository.java

示例6: getWebSockets

import org.vertx.java.core.http.ServerWebSocket; //导入依赖的package包/类
public List<ServerWebSocket> getWebSockets() {
    return Collections.unmodifiableList(webSockets);
}
 
开发者ID:amoAHCP,项目名称:vert.x-spring-microservice-demo,代码行数:4,代码来源:WebSocketRepository.java

示例7: removeWebSocket

import org.vertx.java.core.http.ServerWebSocket; //导入依赖的package包/类
public void removeWebSocket(ServerWebSocket webSocket) {
    webSockets.remove(webSocket);
}
 
开发者ID:amoAHCP,项目名称:vert.x-spring-microservice-demo,代码行数:4,代码来源:WebSocketRepository.java

示例8: addWebSocket

import org.vertx.java.core.http.ServerWebSocket; //导入依赖的package包/类
public void addWebSocket(ServerWebSocket webSocket) {
    webSockets.add(webSocket);
}
 
开发者ID:amoAHCP,项目名称:vertx-samples,代码行数:4,代码来源:WebSocketRepository.java

示例9: getWebSockets

import org.vertx.java.core.http.ServerWebSocket; //导入依赖的package包/类
public List<ServerWebSocket> getWebSockets() {
    return webSockets;
}
 
开发者ID:amoAHCP,项目名称:vertx-samples,代码行数:4,代码来源:WebSocketRepository.java

示例10: handleConnectionClose

import org.vertx.java.core.http.ServerWebSocket; //导入依赖的package包/类
/**
 * handles connection close
 *
 * @param event
 */
private void handleConnectionClose(final Void event, ServerWebSocket socket) {
    repository.removeWebSocket(socket);
}
 
开发者ID:amoAHCP,项目名称:vert.x-spring-microservice-demo,代码行数:9,代码来源:WSEntryVerticle.java


注:本文中的org.vertx.java.core.http.ServerWebSocket类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。