Class: Easyjour::Search

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

Instance Method Summary collapse

Constructor Details

#initialize(service, protocol = :tcp) ⇒ Search

Returns a new instance of Search.



78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/easyjour.rb', line 78

def initialize(service, protocol = :tcp)
  @results = []
  @results_mutex = Mutex.new
  
  @query = DNSSD.browse(Easyjour.type_from_parts(service, protocol)) do |reply|
    DNSSD.resolve(reply.name, reply.type, reply.domain) do |reply|          
      yield(reply) if block_given?

      @results_mutex.synchronize do
        @results << reply
      end
    end
  end
end

Instance Method Details

#resultsObject

Returns the current the results.



94
95
96
97
98
# File 'lib/easyjour.rb', line 94

def results
  @results_mutex.synchronize do
    @results
  end
end

#stopObject

Stop the search.



101
102
103
# File 'lib/easyjour.rb', line 101

def stop
  @query.stop
end