Class: Client::ChannelInitializer

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

Overview

The ChannelInitializer class

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ ChannelInitializer

Returns a new instance of ChannelInitializer.



358
359
360
361
362
363
364
365
366
# File 'lib/client.rb', line 358

def initialize(options = {})
  super()
  @options = options
  @host = @options[:host]
  @port = @options[:port]
  @handlers = []
  @decoder = StringDecoder.new
  @encoder = StringEncoder.new
end

Instance Attribute Details

#decoderObject

Returns the value of attribute decoder.



356
357
358
# File 'lib/client.rb', line 356

def decoder
  @decoder
end

#encoderObject

Returns the value of attribute encoder.



356
357
358
# File 'lib/client.rb', line 356

def encoder
  @encoder
end

#handlersObject

Returns the value of attribute handlers.



356
357
358
# File 'lib/client.rb', line 356

def handlers
  @handlers
end

Instance Method Details

#<<(handler) ⇒ Object



368
369
370
# File 'lib/client.rb', line 368

def <<(handler)
  @handlers << handler
end

#default_handlerObject



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

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

#frame_decoderObject



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

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

#initChannel(channel) ⇒ Object



372
373
374
375
376
377
378
379
380
# File 'lib/client.rb', line 372

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