Class: Foxbat::Server

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

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Server.



11
12
13
14
15
16
17
18
# File 'lib/foxbat/server.rb', line 11

def initialize(host, port, klass, options, &block)
  if options[:secure]
    @context = Security.setup_ssl_context(options[:keystore])
  end
  
  @address = InetSocketAddress.new(host, port)
  @pipeline = Pipeline.new(klass, options, @context, &block)
end

Instance Method Details

#start(threadpool) ⇒ Object



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

def start(threadpool)
  @factory = NioServerSocketChannelFactory.new(threadpool, threadpool)
  @bootstrap = ServerBootstrap.new(@factory)
  @bootstrap.setPipelineFactory(@pipeline)
  @bootstrap.bind(@address)
end

#stopObject



27
28
29
# File 'lib/foxbat/server.rb', line 27

def stop
  @bootstrap.releaseExternalResources
end