lib/whatup/server/server.rb in whatup-0.3.2 vs lib/whatup/server/server.rb in whatup-0.3.3

- old
+ new

@@ -157,19 +157,21 @@ # @param client [Whatup::Server::Client] The client. `client` is assumed # to already belong to a room def handle_chatting client loop do input = client.input! - room = client.room + audience = @clients.reject { |c| c.id == client.id } + .select do |c| + client.room.clients.pluck(:id).include? c.id + end puts "#{client.name}> #{input}" if input == '.exit' + client.puts "Exited `#{client.room.name}`." + audience.each { |c| c.puts "#{client.name}> LEFT" } client.leave_room! - client.puts "Exited `#{room.name}`." break end - room.broadcast except: client do - "#{client.name}> #{input}" - end + audience.each { |c| c.puts "#{client.name}> #{input}" } end end # Receives a username from a client, then creates a new client unless a # client with that username already exists.