當前位置: 首頁>>代碼示例>>Java>>正文


Java WebSocketVersion.V13屬性代碼示例

本文整理匯總了Java中io.netty.handler.codec.http.websocketx.WebSocketVersion.V13屬性的典型用法代碼示例。如果您正苦於以下問題:Java WebSocketVersion.V13屬性的具體用法?Java WebSocketVersion.V13怎麽用?Java WebSocketVersion.V13使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在io.netty.handler.codec.http.websocketx.WebSocketVersion的用法示例。


在下文中一共展示了WebSocketVersion.V13屬性的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getWsVersion

static WebSocketVersion getWsVersion(String str) {
    switch (str) {
        case "0":
            return WebSocketVersion.V00;
        case "7":
            return WebSocketVersion.V07;
        case "8":
            return WebSocketVersion.V08;
        case "13":
            return WebSocketVersion.V13;
    }
    return WebSocketVersion.UNKNOWN;
}
 
開發者ID:codeabovelab,項目名稱:haven-platform,代碼行數:13,代碼來源:Utils.java

示例2: addToPipeline

@Override
public void addToPipeline(final ChannelPipeline pipeline) {
    pipeline.addLast("http-codec", new HttpClientCodec());
    pipeline.addLast("aggregator", new HttpObjectAggregator(8192));

    final WebSocketClientHandshaker handShaker = new WhiteSpaceInPathWebSocketClientHandshaker13(serverUri,
            WebSocketVersion.V13, PROTOCOL, false, createHttpHeaders(httpHeaders), Integer.MAX_VALUE);
    pipeline.addLast("websocket-protocol-handler", new WebSocketClientProtocolHandler(handShaker));

    pipeline.addLast("websocket-frame-codec", new ByteBufToWebSocketFrameCodec());
}
 
開發者ID:saxsys,項目名稱:SynchronizeFX,代碼行數:11,代碼來源:WebsocketChannelInitializer.java

示例3: connect

@Override
public void connect(WsClient client) {
    if (client == null) {
        throw new NullPointerException("client");
    }
    final URLInfo url = client.getUrl();
    String full = url.protocol + "://" + url.host
            + ":" + url.port + url.path;
    URI uri;
    try {
        uri = new URI(full);
    } catch (URISyntaxException e) {
        throw new RuntimeException(e);
    }
    WebSocketVersion v = WebSocketVersion.V13;
    HttpHeaders h = new DefaultHttpHeaders();
    final WebSocketClientHandshaker wsch = WebSocketClientHandshakerFactory
            .newHandshaker(uri, v, null, true, h, Integer.MAX_VALUE);
    final WebSocketHandler handler = new WebSocketHandler(wsch, client);

    Bootstrap b = new Bootstrap();
    b.group(SharedObjects.getLoop());
    b.channel(NioSocketChannel.class);
    b.handler(new ChannelInitializer<SocketChannel>() {
        @Override
        protected void initChannel(SocketChannel ch) throws Exception {
            ChannelPipeline p = ch.pipeline();
            if (url.secure) {
                TrustManagerFactory man = InsecureTrustManagerFactory.INSTANCE;
                SslContext con = SslContext.newClientContext(man);
                p.addLast(con.newHandler(ch.alloc()));
            }

            p.addLast(new HttpClientCodec());
            p.addLast(new HttpObjectAggregator(8192));
            p.addLast(handler);
        }
    });

    ChannelFuture fut = b.connect(url.host, url.port);
    fut.syncUninterruptibly();
    handler.handshakeFuture().syncUninterruptibly();
}
 
開發者ID:IOT-DSA,項目名稱:dslink-java-android,代碼行數:43,代碼來源:AndroidWsProvider.java


注:本文中的io.netty.handler.codec.http.websocketx.WebSocketVersion.V13屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。