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.
|
Source |
extensions/bonjour/init.lua |