}
connector = new NioSocketConnector();
if ( ssl_config != null ) {
SslFilter ssl_filter = new SslFilter( ssl_config.getSSLContext() );
ssl_filter.setUseClientMode( ssl_config.isUseClientMode() );
ssl_filter.setWantClientAuth( ssl_config.isWantClientAuth() );
ssl_filter.setNeedClientAuth( ssl_config.isNeedClientAuth() );
ssl_filter.setEnabledCipherSuites( ssl_config.getEnabledCipherSuites() );
ssl_filter.setEnabledProtocols( ssl_config.getEnabledProtocols() );
connector.getFilterChain().addLast( "ssl", ssl_filter );
}
if ( enable_compression ) {
connector.getFilterChain().addLast( "compress", new CompressionFilter() );
}
connector.getFilterChain().addLast( "intrepid", new ProtocolCodecFilter( codec ) );
// connector.getFilterChain().addLast( "logger", new LoggingFilter() );
connector.setHandler( this );
connector.getSessionConfig().setThroughputCalculationInterval( 1 );
// Disable Nagle's algorithm
connector.getSessionConfig().setTcpNoDelay( true );
// Enable keep alive
connector.getSessionConfig().setKeepAlive( true );
// Make sure sockets don't linger
connector.getSessionConfig().setSoLinger( 0 );
if ( server_address != null || server_port != null ) {
if ( server_port == null ) server_port = Integer.valueOf( 0 );
acceptor = new NioSocketAcceptor();
if ( ssl_config != null ) {
SslFilter ssl_filter = new SslFilter( ssl_config.getSSLContext() );
ssl_filter.setUseClientMode( ssl_config.isUseClientMode() );
ssl_filter.setWantClientAuth( ssl_config.isWantClientAuth() );
ssl_filter.setNeedClientAuth( ssl_config.isNeedClientAuth() );
ssl_filter.setEnabledCipherSuites( ssl_config.getEnabledCipherSuites() );
ssl_filter.setEnabledProtocols( ssl_config.getEnabledProtocols() );
acceptor.getFilterChain().addLast( "ssl", ssl_filter );
}
if ( enable_compression ) {
acceptor.getFilterChain().addLast( "compress", new CompressionFilter() );