Class: Foxbat::Server
- Inherits:
-
Object
- Object
- Foxbat::Server
- Defined in:
- lib/foxbat/server.rb
Instance Method Summary collapse
-
#initialize(host, port, klass, options, &block) ⇒ Server
constructor
A new instance of Server.
- #start(threadpool) ⇒ Object
- #stop ⇒ Object
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, , &block) if [:secure] @context = Security.setup_ssl_context([:keystore]) end @address = InetSocketAddress.new(host, port) @pipeline = Pipeline.new(klass, , @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 |
#stop ⇒ Object
27 28 29 |
# File 'lib/foxbat/server.rb', line 27 def stop @bootstrap.releaseExternalResources end |