A RubyMotion wrapper for the NSNetService (Bonjour)
Ruby
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
app
lib
resources
.gitignore
Gemfile
LICENSE
README.md
Rakefile
motion-net-service.gemspec

README.md

NetService

NetService is a simple wrapper around NSNetService. It publishes and consumes services over Bonjour.

Installation

Command Line:

gem install motion-net-service

Bundler:

gem 'motion-net-service'

Usage

Publishing a NetService (Bonjour) service:

@service = NetService.new(name: "amazaballs", port: 4321) do |ns|
  ns.on_did_publish do
    puts "I published a service"
  end
  ns.on_did_not_resolve do |error|
    puts "Oh crap, I got an error: #{error}"
  end
end

@service.publish

Consuming a service

@n = NetServiceBrowser.search('_ssh._tcp') do |service, more_coming|
  p "name: #{service.name}"
  p "service url: #{service.hostName}:#{service.port}"
  p "More coming?: #{more_coming}"
end

License

MIT, check the LICENSE file.