Project

Salut

0.0
No commit activity in last 3 years
No release in over 3 years
Uses the Objective-C NetService classes to advertise and discover services on the local network
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.0.11
~> 1.1.21
~> 0.8.7
~> 0.6.4
 Project Readme

Salut

Salut is just a little bit of example code of using Bonjour with MacRuby.

If all you want to do is log that callbacks were called back, or just add very little to a callback, then this code will work well for you. But Apple has already done a very good job of distilling Bonjour to the point that even without this gem you would not have to add much code in order to use Bonjour.

Of course, this is not a substitute for reading the Bonjour Overview and related documentation (not even close).

Reference Documentation

Apple's superb documentation of Bonjour and the Bonjour Objective-C interface:

Example Usage

Advertising a hypothetical service:

        service = Salut::Service.new(
           service_type:'_http._tcp.',
          instance_name:'SalutDemo',
                   port:3000
        )
        service.start_advertising

Finding the service using the browser:

        browser = Salut::Browser.new
        # the NSNetServiceBrowserDelegate lists all the possible delegates
        # or look at the 'Delegate methods' group in lib/Salut/Browser.rb
        browser.delegate :"netServiceBrowser:didFindService:moreComing:" do
            |sender, service, more|
            service.resolve # if you want to resolve all services found
            if more
               NSLog('Not up to date yet')
            else
               NSLog('All caught up')
            end
        end
        browser.find_services '_http._tcp.'

If you want to stop advertising:

        service.stop_advertising

You might notice that you aren't seeing the results of the callbacks, this is because they are waiting for the current run loop to cycle. This would happen automatically with a GUI app, but a command line app will have to force the loop to run.

       NSRunLoop.currentRunLoop.run  # => runs indefinitely
       NSRunLoop.currentRunLoop.runUntiDate (Time.now + 5)  # => runs for 5 seconds

You can only use a Service or Browser for one thing at a time, and the API is designed with that assumption in mind.

TODO for 1.0

  • Monitoring and TXT record stuff
  • publishWithOptions default argument
  • implement a mapping for Hot Cocoa

Contributing to Salut

  • Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
  • Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
  • Fork the project
  • Start a feature/bugfix branch
  • Commit and push until you are happy with your contribution
  • Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

Copyright

Copyright (c) 2010-2011 Mark Rada. See LICENSE.txt for further details.