本文整理汇总了Java中io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker类的典型用法代码示例。如果您正苦于以下问题:Java WebSocketClientHandshaker类的具体用法?Java WebSocketClientHandshaker怎么用?Java WebSocketClientHandshaker使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
WebSocketClientHandshaker类属于io.netty.handler.codec.http.websocketx包,在下文中一共展示了WebSocketClientHandshaker类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initChannel
import io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker; //导入依赖的package包/类
@Override
protected void initChannel(SocketChannel channel) throws SSLException {
URI uri = config.getConnectionWebsocketUri();
DefaultHttpHeaders headers = new DefaultHttpHeaders();
headers.add(USER_ID_HEADER, config.getConnectionUserId().toString());
headers.add(USER_PASSWORD_HEADER, config.getConnectionUserPassword());
headers.add(SUPPLIER_ID_HEADER, config.getConnectionServerId());
WebSocketClientHandshaker handshaker = WebSocketClientHandshakerFactory.newHandshaker(uri, WS_VERSION, null, false, headers);
ChannelPipeline pipeline = channel.pipeline();
if (config.isConnectionSecure()) {
try {
SslContext sslContext = SslContext.newClientContext(InsecureTrustManagerFactory.INSTANCE);
pipeline.addLast(sslContext.newHandler(channel.alloc()));
} catch (SSLException e) {
logger.log(Level.SEVERE, "Shutting down client due to unexpected failure to create SSL context", e);
throw e;
}
}
pipeline.addLast(new HttpClientCodec());
pipeline.addLast(new HttpObjectAggregator(8192));
pipeline.addLast(new AudioConnectClientHandler(handshaker));
}
示例2: setup
import io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker; //导入依赖的package包/类
@Before
public void setup() throws Exception {
s = new Server(conf);
s.run();
Connector con = mac.getConnector("root", "secret");
con.securityOperations().changeUserAuthorizations("root", new Authorizations("A", "B", "C", "D", "E", "F"));
this.sessionId = UUID.randomUUID().toString();
AuthCache.getCache().put(sessionId, token);
group = new NioEventLoopGroup();
SslContext ssl = SslContextBuilder.forClient().trustManager(InsecureTrustManagerFactory.INSTANCE).build();
String cookieVal = ClientCookieEncoder.STRICT.encode(Constants.COOKIE_NAME, sessionId);
HttpHeaders headers = new DefaultHttpHeaders();
headers.add(Names.COOKIE, cookieVal);
WebSocketClientHandshaker handshaker = WebSocketClientHandshakerFactory.newHandshaker(LOCATION,
WebSocketVersion.V13, (String) null, false, headers);
handler = new ClientHandler(handshaker);
Bootstrap boot = new Bootstrap();
boot.group(group).channel(NioSocketChannel.class).handler(new ChannelInitializer<SocketChannel>() {
@Override
protected void initChannel(SocketChannel ch) throws Exception {
ch.pipeline().addLast("ssl", ssl.newHandler(ch.alloc(), "127.0.0.1", WS_PORT));
ch.pipeline().addLast(new HttpClientCodec());
ch.pipeline().addLast(new HttpObjectAggregator(8192));
ch.pipeline().addLast(handler);
}
});
ch = boot.connect("127.0.0.1", WS_PORT).sync().channel();
// Wait until handshake is complete
while (!handshaker.isHandshakeComplete()) {
sleepUninterruptibly(500, TimeUnit.MILLISECONDS);
LOG.debug("Waiting for Handshake to complete");
}
}
示例3: WebSocketTargetHandler
import io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker; //导入依赖的package包/类
public WebSocketTargetHandler(WebSocketClientHandshaker handshaker, boolean isSecure, String requestedUri,
String target, WebSocketConnectorListener webSocketConnectorListener) {
this.handshaker = handshaker;
this.isSecure = isSecure;
this.requestedUri = requestedUri;
this.target = target;
this.connectorListener = webSocketConnectorListener;
handshakeFuture = null;
}
示例4: addToPipeline
import io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker; //导入依赖的package包/类
@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());
}
示例5: WebSocketClientHandler
import io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker; //导入依赖的package包/类
public WebSocketClientHandler(long uid, WebSocketClientHandshaker handshaker) {
this.uid = uid;
this.handshaker = handshaker;
}
示例6: ClientHandler
import io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker; //导入依赖的package包/类
public ClientHandler(WebSocketClientHandshaker handshaker) {
this.handshaker = handshaker;
}
示例7: AudioConnectClientHandler
import io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker; //导入依赖的package包/类
private AudioConnectClientHandler(WebSocketClientHandshaker handshaker) {
this.handshaker = handshaker;
}
示例8: MeetupWebSocketClientHandler
import io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker; //导入依赖的package包/类
MeetupWebSocketClientHandler(WebSocketClientHandshaker handshaker, RSVPProducer rsvpProducer) {
this.handshaker = handshaker;
this.rsvpProducer = rsvpProducer;
}
示例9: WebSocketClientHandler
import io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker; //导入依赖的package包/类
public WebSocketClientHandler(final WebSocketClientHandshaker handshaker) {
this.handshaker = handshaker;
}
示例10: WebSocketClientHandler
import io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker; //导入依赖的package包/类
public WebSocketClientHandler(WebSocketClientHandshaker handshaker, CountDownLatch latch) {
this.handshaker = handshaker;
this.latch = latch;
this.isOpen = true;
}
示例11: onOpen
import io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker; //导入依赖的package包/类
@Override
public void onOpen(WebSocketClientHandshaker handShaker) {
// TODO Auto-generated method stub
}
示例12: onOpen
import io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker; //导入依赖的package包/类
@Override
public void onOpen(WebSocketClientHandshaker handShaker) {
logger.log(Level.INFO, "onOpen");
}
示例13: WebSocketClientHandler
import io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker; //导入依赖的package包/类
public WebSocketClientHandler(WebSocketClientHandshaker handshaker) {
this.handshaker = handshaker;
}
示例14: WebSocketClientHandler
import io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker; //导入依赖的package包/类
public WebSocketClientHandler(WebSocketClientHandshaker handshaker) {
this.handshaker = handshaker;
}
示例15: MessageReceiverWebSocketClientHandler
import io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker; //导入依赖的package包/类
public MessageReceiverWebSocketClientHandler(WebSocketClientHandshaker handshaker) {
this.handshaker = handshaker;
}