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 = nil) ⇒ Server

Returns a new instance of Server.



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

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

Instance Method Details

#start(threadpool) ⇒ Object



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

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

#stopObject



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

def stop
end