Search in sources :

Example 1 with WebSocketClientHandshakerFactory

use of org.jboss.netty.handler.codec.http.websocketx.WebSocketClientHandshakerFactory in project sockjs-netty by cgbystrom.

the class WebSocketClient method connect.

@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)));
    }
}
Also used : WebSocketClientHandshakerFactory(org.jboss.netty.handler.codec.http.websocketx.WebSocketClientHandshakerFactory) LocalAddress(org.jboss.netty.channel.local.LocalAddress) InetSocketAddress(java.net.InetSocketAddress) LocalClientChannelFactory(org.jboss.netty.channel.local.LocalClientChannelFactory) URI(java.net.URI)

Aggregations

InetSocketAddress (java.net.InetSocketAddress)1 URI (java.net.URI)1 LocalAddress (org.jboss.netty.channel.local.LocalAddress)1 LocalClientChannelFactory (org.jboss.netty.channel.local.LocalClientChannelFactory)1 WebSocketClientHandshakerFactory (org.jboss.netty.handler.codec.http.websocketx.WebSocketClientHandshakerFactory)1