Class: Columbus::Client
- Inherits:
-
Object
- Object
- Columbus::Client
- Defined in:
- lib/columbus/client.rb
Class Attribute Summary collapse
-
.discover_type ⇒ Object
Returns the value of attribute discover_type.
Class Method Summary collapse
Class Attribute Details
.discover_type ⇒ Object
Returns the value of attribute discover_type.
24 25 26 |
# File 'lib/columbus/client.rb', line 24 def discover_type @discover_type end |
Class Method Details
.discover(timeout = 5) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/columbus/client.rb', line 30 def discover(timeout=5) waiting_thread = Thread.current dns = DNSSD.browse discover_type do |reply| DNSSD.resolve reply.name, reply.type, reply.domain do |resolve_reply| service = FoundService.new(reply.name, resolve_reply.target, resolve_reply.port, (resolve_reply.text_record['description'].to_s rescue "")) begin yield service rescue Done waiting_thread.run end end end sleep timeout dns.stop end |
.list ⇒ Object
57 58 59 60 61 62 63 |
# File 'lib/columbus/client.rb', line 57 def list service_list.each do |service| puts "=== #{service.name} on #{service.host}:#{service.port} ===" puts " found #{service.name}" puts " #{service.description}" end end |
.service_list ⇒ Object
51 52 53 54 55 |
# File 'lib/columbus/client.rb', line 51 def service_list list = Set.new discover { |obj| list << obj } return list end |