/** * Instances a new handshaker * * @param webSocketURL * URL for web socket communications. e.g "ws://myhost.com/mypath". * Subsequent web socket frames will be sent to this URL. * @param version * Version of web socket specification to use to connect to the server * @param subprotocol * Sub protocol request sent to the server. Null if no sub-protocol support is required. * @param allowExtensions * Allow extensions to be used in the reserved bits of the web socket frame * @param customHeaders * Custom HTTP headers to send during the handshake * @throws WebSocketHandshakeException */ public WebSocketClientHandshaker newHandshaker(URI webSocketURL, WebSocketVersion version, String subprotocol, boolean allowExtensions, Map<String, String> customHeaders) { return newHandshaker(webSocketURL, version, subprotocol, allowExtensions, customHeaders, Long.MAX_VALUE); }
@Override public ChannelFuture connect() throws URISyntaxException { this.sessionId = UUID.randomUUID().toString(); URI sockJsUri = new URI("http", uri.getUserInfo(), uri.getHost(), uri.getPort(), uri.getPath() + "/999/" + sessionId + "/websocket", uri.getQuery(), uri.getFragment()); this.wsHandshaker = new WebSocketClientHandshakerFactory().newHandshaker( sockJsUri, WebSocketVersion.V13, null, false, null); if (bootstrap.getFactory() instanceof LocalClientChannelFactory) { return bootstrap.connect(new LocalAddress(getPort(uri))); } else { return bootstrap.connect(new InetSocketAddress(uri.getHost(), getPort(uri))); } }