lib/foxbat/server.rb in foxbat-0.2.0 vs lib/foxbat/server.rb in foxbat-0.2.3
- old
+ new
@@ -6,25 +6,27 @@
module Foxbat
class Server
- def initialize(host, port, klass, options, block=nil)
+ 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 || block, @context)
+ @pipeline = Pipeline.new(klass, options, @context, &block)
end
def start(threadpool)
@factory = NioServerSocketChannelFactory.new(threadpool, threadpool)
@bootstrap = ServerBootstrap.new(@factory)
@bootstrap.setPipelineFactory(@pipeline)
@bootstrap.bind(@address)
end
def stop
+ @bootstrap.releaseExternalResources
end
end
end