io.netty.handler.codec.http.websocketx.WebSocketServerProtocolHandler.HandshakeComplete Java Examples
The following examples show how to use
io.netty.handler.codec.http.websocketx.WebSocketServerProtocolHandler.HandshakeComplete.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TunnelSocketFrameHandler.java From arthas with Apache License 2.0 | 6 votes |
@Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { if (evt instanceof HandshakeComplete) { HandshakeComplete handshake = (HandshakeComplete) evt; // http request uri String uri = handshake.requestUri(); logger.info("websocket handshake complete, uri: {}", uri); MultiValueMap<String, String> parameters = UriComponentsBuilder.fromUriString(uri).build().getQueryParams(); String method = parameters.getFirst("method"); if ("connectArthas".equals(method)) { // form browser connectArthas(ctx, parameters); } else if ("agentRegister".equals(method)) { // form arthas agent, register agentRegister(ctx, uri); } if ("openTunnel".equals(method)) { // from arthas agent open tunnel String clientConnectionId = parameters.getFirst("clientConnectionId"); openTunnel(ctx, clientConnectionId); } } else { ctx.fireUserEventTriggered(evt); } }
Example #2
Source File: WebSocketServerInitializer.java From util4j with Apache License 2.0 | 6 votes |
@SuppressWarnings("deprecation") @Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt)throws Exception { if (evt == WebSocketServerProtocolHandler.ServerHandshakeStateEvent.HANDSHAKE_COMPLETE) {//旧版本 log.debug("excute webSocketHandComplete……"); webSocketHandComplete(ctx); ctx.pipeline().remove(this); log.debug("excuted webSocketHandComplete:"+ctx.pipeline().toMap().toString()); return; } if(evt instanceof HandshakeComplete) {//新版本 HandshakeComplete hc=(HandshakeComplete)evt; log.debug("excute webSocketHandComplete……,HandshakeComplete="+hc); webSocketHandComplete(ctx); ctx.pipeline().remove(this); log.debug("excuted webSocketHandComplete:"+ctx.pipeline().toMap().toString()); return; } super.userEventTriggered(ctx, evt); }
Example #3
Source File: NettyServer.java From qpid-jms with Apache License 2.0 | 5 votes |
@Override public void userEventTriggered(ChannelHandlerContext context, Object payload) { if (payload instanceof HandshakeComplete) { handshakeComplete = (HandshakeComplete) payload; handshakeCompletion.countDown(); } }
Example #4
Source File: NettyServer.java From qpid-jms with Apache License 2.0 | 4 votes |
public HandshakeComplete getHandshakeComplete() { return handshakeComplete; }
Example #5
Source File: NettyWsTransportTest.java From qpid-jms with Apache License 2.0 | 4 votes |
@Test(timeout = 60 * 1000) public void testConfiguredHttpHeadersArriveAtServer() throws Exception { try (NettyEchoServer server = createEchoServer(createServerOptions())) { server.start(); int port = server.getServerPort(); URI serverLocation = new URI("tcp://localhost:" + port); TransportOptions clientOptions = createClientOptions(); clientOptions.getHttpHeaders().put("test-header1", "FOO"); clientOptions.getHttpHeaders().put("test-header2", "BAR"); Transport transport = createTransport(serverLocation, testListener, clientOptions); try { transport.connect(null, null); LOG.info("Connected to server:{} as expected.", serverLocation); } catch (Exception e) { fail("Should have connected to the server at " + serverLocation + " but got exception: " + e); } assertTrue(transport.isConnected()); assertEquals(serverLocation, transport.getRemoteLocation()); assertTrue("HandshakeCompletion not set within given time", server.awaitHandshakeCompletion(2000)); HandshakeComplete handshake = server.getHandshakeComplete(); assertNotNull("completion should not be null", handshake); HttpHeaders requestHeaders = handshake.requestHeaders(); assertTrue(requestHeaders.contains("test-header1")); assertTrue(requestHeaders.contains("test-header2")); assertEquals("FOO", requestHeaders.get("test-header1")); assertEquals("BAR", requestHeaders.get("test-header2")); transport.close(); } assertTrue(!transportClosed); // Normal shutdown does not trigger the event. assertTrue(exceptions.isEmpty()); assertTrue(data.isEmpty()); }