class Tojour::Jour

Public Class Methods

list(&block) click to toggle source
# File lib/tojour/jour.rb, line 28
def self.list(&block)
  %w[file io].each do |kind|
    DNSSD.browse("_tojour_#{kind}._tcp") do |r|
      block.call(kind, r.name)
    end
  end
  sleep 5
end
new(name, kind) click to toggle source
# File lib/tojour/jour.rb, line 5
def initialize(name, kind)
  @name = name
  @protocol = "_tojour_#{kind}._tcp"
end

Public Instance Methods

register(port, &block) click to toggle source
# File lib/tojour/jour.rb, line 10
def register(port, &block)
  DNSSD::register(@name, @protocol, nil, port) do |r|
    block.call(r)
  end
  loop do
    sleep 1
  end
end
resolve(&block) click to toggle source
# File lib/tojour/jour.rb, line 19
def resolve(&block)
  DNSSD.resolve(@name, @protocol, 'local') do |r|
    block.call(r)
  end
  loop do
    sleep 1
  end
end