Class: OSCAccess::Zeroconf::Service

Inherits:
Object
  • Object
show all
Defined in:
lib/osc-access/zeroconf.rb

Instance Method Summary collapse

Constructor Details

#initialize(name, port) ⇒ Service

Returns a new instance of Service.



25
26
27
# File 'lib/osc-access/zeroconf.rb', line 25

def initialize(name, port)
  @name, @port = name, port
end

Instance Method Details

#start ⇒ Object



29
30
31
32
33
34
35
36
# File 'lib/osc-access/zeroconf.rb', line 29

def start
  @thread = Thread.new do
    registrar = DNSSD::Service.new
    registrar.register @name, '_osc._udp', nil, @port do |r|
    end
  end
  self
end

#stop ⇒ Object



38
39
40
41
# File 'lib/osc-access/zeroconf.rb', line 38

def stop
  @thread.kill unless @thread.nil?
  self
end