Class: WebSocket::ClientChannelInitializer
- Defined in:
- lib/websocket_client.rb
Overview
The ClientChannelInitializer class
Constant Summary collapse
- FrameDecoderBufferSize =
bytes
8192
Instance Method Summary collapse
- #default_handler ⇒ Object
- #handshaker ⇒ Object
- #initChannel(channel) ⇒ Object
-
#initialize(host, port, scheme, options = {}) ⇒ ClientChannelInitializer
constructor
A new instance of ClientChannelInitializer.
- #ssl_context ⇒ Object
Constructor Details
#initialize(host, port, scheme, options = {}) ⇒ ClientChannelInitializer
Returns a new instance of ClientChannelInitializer.
375 376 377 378 379 380 381 |
# File 'lib/websocket_client.rb', line 375 def initialize(host, port, scheme, = {}) super() @host = host @port = port @options = @ssl_ctx = ssl_context if /wss/i.match?(scheme) end |
Instance Method Details
#default_handler ⇒ Object
393 394 395 |
# File 'lib/websocket_client.rb', line 393 def default_handler @default_handler ||= ::WebSocket::ClientChannelHandler.new(handshaker) end |
#handshaker ⇒ Object
383 384 385 386 387 388 389 390 391 |
# File 'lib/websocket_client.rb', line 383 def handshaker @handshaker ||= WebSocketClientHandshakerFactory.newHandshaker( @options[:uri], @options[:websocket_version], @options[:subprotocol], @options[:allow_extensions], @options[:default_headers] ) end |
#initChannel(channel) ⇒ Object
403 404 405 406 407 408 409 410 411 412 |
# File 'lib/websocket_client.rb', line 403 def initChannel(channel) pipeline = channel.pipeline() pipeline.addLast(@ssl_ctx.newHandler(channel.alloc(), @host, @port)) unless @ssl_ctx.nil? pipeline.addLast( HttpClientCodec.new, HttpObjectAggregator.new(FrameDecoderBufferSize), WebSocketClientCompressionHandler::INSTANCE ) pipeline.addLast(default_handler) end |
#ssl_context ⇒ Object
397 398 399 400 401 |
# File 'lib/websocket_client.rb', line 397 def ssl_context context_builder = SslContextBuilder.forClient() trust_manager = context_builder.trustManager(InsecureTrustManagerFactory::INSTANCE) trust_manager.build() end |