class Wifidiag::Collector
Collect client and AP information from +an adapter+
Attributes
adapter[R]
last_update[R]
Public Class Methods
new(adapter)
click to toggle source
# File lib/wifidiag/collector.rb, line 6 def initialize(adapter) @lock = Mutex.new @adapter = adapter @clients = nil @clients_by_ip_address = nil @clients_by_mac_address = nil @last_update = nil end
Public Instance Methods
client_data_for_ip_address(address)
click to toggle source
# File lib/wifidiag/collector.rb, line 50 def client_data_for_ip_address(address) @clients_by_ip_address[address] end
client_data_for_mac_address(address)
click to toggle source
# File lib/wifidiag/collector.rb, line 54 def client_data_for_mac_address(address) @clients_by_mac_address[address] end
collect()
click to toggle source
# File lib/wifidiag/collector.rb, line 38 def collect @lock.synchronize do clients = adapter.collect() clients_by_ip_address = clients.map { |_| [_.ip_address, _] }.to_h clients_by_mac_address = clients.map { |_| [_.mac_address, _] }.to_h @clients = clients @clients_by_ip_address = clients_by_ip_address @clients_by_mac_address = clients_by_mac_address @last_update = Time.now end end
start_periodic_update(interval)
click to toggle source
# File lib/wifidiag/collector.rb, line 19 def start_periodic_update(interval) # XXX: self.collect Thread.new do loop do begin self.collect sleep interval rescue Exception => e $stderr.puts "Periodic update error: #{e.inspect}" e.backtrace.each do |x| $stderr.puts "\t#{x}" end sleep interval end end end end