Class: Telnet::ClientChannelInitializer

Inherits:
Object
  • Object
show all
Defined in:
lib/telnet_client.rb

Overview

The ClientChannelInitializer class

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host, port, options = {}) ⇒ ClientChannelInitializer

Returns a new instance of ClientChannelInitializer.



356
357
358
359
360
361
362
363
# File 'lib/telnet_client.rb', line 356

def initialize(host, port, options = {})
  super()
  @host = host
  @port = port
  @options = options
  @decoder = StringDecoder.new
  @encoder = StringEncoder.new
end

Instance Attribute Details

#decoderObject

Returns the value of attribute decoder.



354
355
356
# File 'lib/telnet_client.rb', line 354

def decoder
  @decoder
end

#encoderObject

Returns the value of attribute encoder.



354
355
356
# File 'lib/telnet_client.rb', line 354

def encoder
  @encoder
end

Instance Method Details

#default_handlerObject



365
366
367
# File 'lib/telnet_client.rb', line 365

def default_handler
  @default_handler ||= ::Telnet::ModularHandler.new
end

#frame_decoderObject



378
379
380
# File 'lib/telnet_client.rb', line 378

def frame_decoder
  DelimiterBasedFrameDecoder.new(@options[:max_frame_length], @options[:delimiter])
end

#initChannel(channel) ⇒ Object



369
370
371
372
373
374
375
376
# File 'lib/telnet_client.rb', line 369

def initChannel(channel)
  pipeline = channel.pipeline()
  pipeline.addLast(ssl_handler(channel)) if @options[:ssl]
  # pipeline.addLast(frame_decoder)
  pipeline.addLast(decoder)
  pipeline.addLast(encoder)
  pipeline.addLast(default_handler)
end

#ssl_contextObject



386
387
388
# File 'lib/telnet_client.rb', line 386

def ssl_context
  nil # TODO: Implement
end

#ssl_handler(channel) ⇒ Object



382
383
384
# File 'lib/telnet_client.rb', line 382

def ssl_handler(channel)
  ssl_context&.newHandler(channel.alloc(), @host, @port)
end