Skip to content

Instantly share code, notes, and snippets.

@queso
Created April 7, 2013 18:43
Show Gist options
  • Save queso/5331849 to your computer and use it in GitHub Desktop.
Save queso/5331849 to your computer and use it in GitHub Desktop.
def self.discover(timeout = 6)
Timeout::timeout(timeout) do
dns = DNSSD.browse "_airplay._tcp" do |reply|
DNSSD.resolve reply.name, reply.type, reply.domain do |resolve_reply|
device = self.find_or_create_by_hostname(hostname: resolve_reply.target)
device.update_attributes(last_discovered_at: Time.now, mac_address: resolve_reply.text_record['deviceid'])
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment