Module: Adhoc::DNSSD

Defined in:
lib/adhoc/dnssd.rb

Overview

DNS-SD service discovery.

Class Method Summary

Class Method Details

+ (Object) discover(service, options = {}, &block)

Discovers DNS-SD services asynchronously.



21
22
23
24
25
26
27
28
# File 'lib/adhoc/dnssd.rb', line 21

def self.discover(service, options = {}, &block)
  service = Service.for(service)
  ::DNSSD.browse(service.type) do |reply|
    ::DNSSD.resolve(reply) do |reply|
      block.call(service.new(reply))
    end
  end
end

+ (Object) discover!(service, options = {}, &block)

Discovers DNS-SD services synchronously.



9
10
11
12
13
14
15
16
17
# File 'lib/adhoc/dnssd.rb', line 9

def self.discover!(service, options = {}, &block)
  query = discover(service, options, &block)
  if options[:timeout]
    sleep options[:timeout].to_f
  else
    sleep # wait indefinitely
  end
  query.stop
end