本文整理匯總了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;
}
示例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());
}
示例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();
}