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.



352
353
354
355
356
357
358
359
# File 'lib/telnet_client.rb', line 352

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.



350
351
352
# File 'lib/telnet_client.rb', line 350

def decoder
  @decoder
end

#encoderObject

Returns the value of attribute encoder.



350
351
352
# File 'lib/telnet_client.rb', line 350

def encoder
  @encoder
end

Instance Method Details

#default_handlerObject



361
362
363
# File 'lib/telnet_client.rb', line 361

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

#frame_decoderObject



374
375
376
# File 'lib/telnet_client.rb', line 374

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

#initChannel(channel) ⇒ Object



365
366
367
368
369
370
371
372
# File 'lib/telnet_client.rb', line 365

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



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

def ssl_context
  nil # TODO: Implement
end

#ssl_handler(channel) ⇒ Object



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

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