Signature |
hs.bonjour:findServices(type, [domain], [callback]) -> browserObject |
Type |
Method |
Description |
Find advertised services of the type specified. |
Parameters |
type - a string specifying the type of service to discover on your network. This string should be specified in the format of '_service._protocol.' where _protocol is one of '_tcp' or '_udp'. Examples of common service types can be found in hs.bonjour.serviceTypes.
domain - an optional string specifying the domain to look for advertised services in. The domain should end with a period. If you omit this parameter, the default registration domain will be used, usually "local."
callback - a callback function which will be invoked as service advertisements meeting the specified criteria are discovered. The callback function should expect 2-5 arguments as follows:
- if a service is discovered or advertising for the service is terminated, the arguments will be: * the browserObject * the string "domain" * a boolean indicating whether the service is being advertised (true) or should be removed because advertisments for the service are being terminated (false) * the serviceObject for the specific advertisement (see
hs.bonjour.service ) * a boolean indicating if more advertisements are expected (true) or if the macOS believes that there are no more advertisements to be discovered (false).
- if an error occurs, the callback arguments will be: * the browserObject * the string "error" * a string specifying the specific error that occurred
|
Returns |
|
Notes |
macOS will indicate when it believes there are no more advertisements of the type specified by type in domain by marking the last argument to your callback function as false. This is a best guess and may not always be accurate if your network is slow or some servers on your network are particularly slow to respond.
In addition, if you leave the browser running this method, you will get future updates when services are removed because of server shutdowns or added because of new servers being booted up.
Leaving the browser running does consume some system resources though, so you will have to determine, based upon your specific requirements, if this is a concern for your specific task or not. To terminate the browser when you have rtrieved all of the infomration you reuqire, you can use the hs.bonjour:stop method.
The special type "_services._dns-sd._udp." can be used to discover the types of services being advertised on your network. The hs.bonjour.service objects returned to the callback function cannot actually be resolved, but you can use the hs.bonjour.service:name method to create a list of services that are currently present and being advertised.
The special domain "dns-sd.org." can be specified to find services advertised through Wide-Area Service Discovery as described at http://www.dns-sd.org. This can be used to discover a limited number of globally available sites on the internet, especially with a service type of _http._tcp. .
- In theory, with additional software, you may be able to publish services on your machine for Wide-Area Service discovery using this domain with
hs.bonjour.service.new but the local dns server requirements and security implications of doing so are beyond the scope of this documentation. You should refer to http://www.dns-sd.org and your local DNS Server administrator or provider for more details.
|
Source |
extensions/bonjour/bonjour.lua line 65 |