diff --git a/lib/librevox/listener/inbound.rb b/lib/librevox/listener/inbound.rb index d94b2ab..9717f2e 100644 --- a/lib/librevox/listener/inbound.rb +++ b/lib/librevox/listener/inbound.rb @@ -45,7 +45,6 @@ def run_session end connection_completed - sleep # keep session alive for event hooks and child tasks end def connection_completed diff --git a/lib/librevox/listener/outbound.rb b/lib/librevox/listener/outbound.rb index c4e13a1..8f585fb 100644 --- a/lib/librevox/listener/outbound.rb +++ b/lib/librevox/listener/outbound.rb @@ -50,7 +50,6 @@ def run_session send_message "myevents" send_message "linger" session_initiated - sleep # keep session alive for event hooks and child tasks end def handle_response diff --git a/lib/librevox/server.rb b/lib/librevox/server.rb index 6dfd31a..3d24161 100644 --- a/lib/librevox/server.rb +++ b/lib/librevox/server.rb @@ -27,7 +27,10 @@ def accept(socket, _address) end def run - @endpoint.accept(&method(:accept)) + Async do |task| + @endpoint.accept(&method(:accept)) + task.children.each(&:wait) + end end end end