lib/backport/server/connectable.rb in backport-0.3.0 vs lib/backport/server/connectable.rb in backport-1.0.0

- old
+ new

@@ -4,13 +4,13 @@ # # Connectable servers check clients for incoming data on each tick. # module Connectable def tick - clients.each do |client| - input = client.read - client.sending input unless input.nil? + mutex.synchronize do + clients.each(&:tick) + clients.delete_if(&:stopped?) end end def starting clients.map(&:run) @@ -21,9 +21,15 @@ end # @return [Array<Client>] def clients @clients ||= [] + end + + private + + def mutex + @mutex ||= Mutex.new end end end end