Module: HeyIAmOverHere

Defined in:
lib/hey_i_am_over_here.rb,
lib/hey_i_am_over_here/version.rb

Constant Summary collapse

SERVICE =
"_http._tcp"
VERSION =
"0.0.1"

Class Method Summary collapse

Class Method Details

.publish(name = 'My App', port = 3000, description = '') ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/hey_i_am_over_here.rb', line 9

def self.publish(name = 'My App', port = 3000, description = '')
  STDERR.puts "Publishing #{name} on #{port}"
  port = port.to_i

  tr = DNSSD::TextRecord.new
  tr["description"] = description

  DNSSD.register(name, SERVICE, "local", port.to_i, tr.encode) do |reply|
    STDERR.puts "Announcing #{name}..."
  end
end