Class: Airplay::Browser

Inherits:
Object
  • Object
show all
Defined in:
lib/airplay/browser.rb

Overview

Public: Browser class to find Airplay-enabled devices in the network

Constant Summary collapse

NoDevicesFound =
Class.new(StandardError)
SEARCH =
"_airplay._tcp."

Instance Method Summary collapse

Constructor Details

#initializeBrowser

Returns a new instance of Browser.



15
16
17
# File 'lib/airplay/browser.rb', line 15

def initialize
  @logger = Airplay::Logger.new("airplay::browser")
end

Instance Method Details

#browseObject

Public: Browses in the search of devices and adds them to the nodes

Returns nothing or raises NoDevicesFound if there are no devices



23
24
25
26
27
28
29
30
31
32
# File 'lib/airplay/browser.rb', line 23

def browse
  timeout(5) do
    DNSSD.browse!(SEARCH) do |node|
      resolve(node)
      break unless node.flags.more_coming?
    end
  end
rescue Timeout::Error => e
  raise NoDevicesFound
end

#devicesObject

Public: Access to the node list

Returns the Devices list object



38
39
40
# File 'lib/airplay/browser.rb', line 38

def devices
  @_devices ||= Devices.new
end