Class: Adelnor::AsyncServer
- Inherits:
-
BaseServer
- Object
- BaseServer
- Adelnor::AsyncServer
- Defined in:
- lib/adelnor/async_server.rb
Instance Method Summary collapse
-
#initialize(rack_app, port, options = {}) ⇒ AsyncServer
constructor
A new instance of AsyncServer.
- #run ⇒ Object
Methods inherited from BaseServer
#handle, #rack_data, #read_request_message, run, #welcome_message
Constructor Details
#initialize(rack_app, port, options = {}) ⇒ AsyncServer
Returns a new instance of AsyncServer.
9 10 11 12 13 14 |
# File 'lib/adelnor/async_server.rb', line 9 def initialize(rack_app, port, = {}) super(rack_app, port, ) scheduler = Async::Scheduler.new Fiber.set_scheduler(scheduler) end |
Instance Method Details
#run ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/adelnor/async_server.rb', line 16 def run Async do |task| loop do client, = @socket.accept task.async do handle(client) client.close end end end end |