Class: Client::Channelizer
- Inherits:
-
ChannelInitializer
- Object
- ChannelInitializer
- Client::Channelizer
- Defined in:
- lib/tcp_server/client.rb
Overview
The Channelizer class
Instance Attribute Summary collapse
-
#decoder ⇒ Object
Returns the value of attribute decoder.
-
#encoder ⇒ Object
Returns the value of attribute encoder.
-
#handlers ⇒ Object
Returns the value of attribute handlers.
Instance Method Summary collapse
- #<<(handler) ⇒ Object
- #default_handler ⇒ Object
- #frame_decoder ⇒ Object
- #initChannel(channel) ⇒ Object
-
#initialize(options = {}) ⇒ Channelizer
constructor
A new instance of Channelizer.
Constructor Details
#initialize(options = {}) ⇒ Channelizer
Returns a new instance of Channelizer.
362 363 364 365 366 367 368 369 370 |
# File 'lib/tcp_server/client.rb', line 362 def initialize( = {}) super() @options = @host = @options[:host] @port = @options[:port] @handlers = [] @decoder = StringDecoder.new @encoder = StringEncoder.new end |
Instance Attribute Details
#decoder ⇒ Object
Returns the value of attribute decoder.
360 361 362 |
# File 'lib/tcp_server/client.rb', line 360 def decoder @decoder end |
#encoder ⇒ Object
Returns the value of attribute encoder.
360 361 362 |
# File 'lib/tcp_server/client.rb', line 360 def encoder @encoder end |
#handlers ⇒ Object
Returns the value of attribute handlers.
360 361 362 |
# File 'lib/tcp_server/client.rb', line 360 def handlers @handlers end |
Instance Method Details
#<<(handler) ⇒ Object
372 373 374 |
# File 'lib/tcp_server/client.rb', line 372 def <<(handler) @handlers << handler end |
#default_handler ⇒ Object
391 392 393 |
# File 'lib/tcp_server/client.rb', line 391 def default_handler @default_handler ||= ::Client::ModularHandler.new end |
#frame_decoder ⇒ Object
386 387 388 389 |
# File 'lib/tcp_server/client.rb', line 386 def frame_decoder DelimiterBasedFrameDecoder.new( @options[:max_frame_length], @options[:delimiter]) end |
#initChannel(channel) ⇒ Object
376 377 378 379 380 381 382 383 384 |
# File 'lib/tcp_server/client.rb', line 376 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 |