Module: Telnet::ClientInitializationMethods
- Included in:
- Client
- Defined in:
- lib/telnet_client.rb
Overview
The ClientInitializationMethods module
Instance Method Summary collapse
- #bootstrap ⇒ Object
- #channel_initializer ⇒ Object
- #client_group ⇒ Object
- #configure_handlers(*handlers, &block) ⇒ Object
- #init(options) ⇒ Object
- #logging_handler ⇒ Object
Instance Method Details
#bootstrap ⇒ Object
65 66 67 68 69 70 71 |
# File 'lib/telnet_client.rb', line 65 def bootstrap @bootstrap = Bootstrap.new @bootstrap.group(client_group) @bootstrap.channel(::Telnet::CHANNEL_TYPE) @bootstrap.handler(logging_handler) if @options[:log_requests] @bootstrap.handler(channel_initializer) end |
#channel_initializer ⇒ Object
81 82 83 |
# File 'lib/telnet_client.rb', line 81 def channel_initializer @channel_initializer ||= ::Telnet::ClientChannelInitializer.new(@host, @port, @options) end |
#client_group ⇒ Object
73 74 75 |
# File 'lib/telnet_client.rb', line 73 def client_group @client_group ||= NioEventLoopGroup.new end |
#configure_handlers(*handlers, &block) ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/telnet_client.rb', line 85 def configure_handlers(*handlers, &block) channel_initializer.default_handler.add_listener(self) channel_initializer.default_handler.listeners.addAll(handlers) @user_app = block @application_handler = lambda do |ctx, msg| if @user_app.nil? || @user_app.arity == 1 @queue.add(msg) else @user_app.call(ctx, msg) end end end |
#init(options) ⇒ Object
58 59 60 61 62 63 |
# File 'lib/telnet_client.rb', line 58 def init() @options = @host = [:host] @port = [:port] @queue = java.util.concurrent.LinkedBlockingQueue.new end |
#logging_handler ⇒ Object
77 78 79 |
# File 'lib/telnet_client.rb', line 77 def logging_handler @logging_handler ||= LoggingHandler.new(LogLevel::INFO) end |