Class: Foxbat::Client

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

Instance Method Summary collapse

Constructor Details

#initialize(host, port, klass, options, &block) ⇒ Client

Returns a new instance of Client.



8
9
10
11
12
13
14
15
16
# File 'lib/foxbat/client.rb', line 8

def initialize(host, port, klass, options, &block)
  if options[:secure]
    @context = Security.setup_ssl_client_context
  end

  @group = DefaultChannelGroup.new
  @address = InetSocketAddress.new(host, port)
  @pipeline = Pipeline.new(klass, @group, true, options, @context, &block)
end

Instance Method Details

#start(threadpool) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/foxbat/client.rb', line 18

def start(threadpool)
  factory = NioClientSocketChannelFactory.new(threadpool, threadpool)
  @bootstrap = ClientBootstrap.new(factory)
  @bootstrap.setPipelineFactory(@pipeline)
  @bootstrap.setOption("child.tcpNoDelay", true)
  @bootstrap.setOption("child.keepAlive", true)
  @bootstrap.connect(@address)
end