A Bonjour/\+Zeroconf protocol implementation in pure Java\+Script. Publish services on the local network or discover existing services using multicast DNS.

\href{https://travis-ci.org/watson/bonjour}{\texttt{ }} \href{https://github.com/feross/standard}{\texttt{ }}\hypertarget{md_sfcode_node_modules_bonjour_README_autotoc_md4253}{}\doxysection{Installation}\label{md_sfcode_node_modules_bonjour_README_autotoc_md4253}

\begin{DoxyCode}{0}
\DoxyCodeLine{npm install bonjour }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_bonjour_README_autotoc_md4254}{}\doxysection{Usage}\label{md_sfcode_node_modules_bonjour_README_autotoc_md4254}

\begin{DoxyCode}{0}
\DoxyCodeLine{var bonjour = require('bonjour')()}
\DoxyCodeLine{}
\DoxyCodeLine{// advertise an HTTP server on port 3000}
\DoxyCodeLine{bonjour.publish(\{ name: 'My Web Server', type: 'http', port: 3000 \})}
\DoxyCodeLine{}
\DoxyCodeLine{// browse for all http services}
\DoxyCodeLine{bonjour.find(\{ type: 'http' \}, function (service) \{}
\DoxyCodeLine{  console.log('Found an HTTP server:', service)}
\DoxyCodeLine{\}) }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_bonjour_README_autotoc_md4255}{}\doxysection{API}\label{md_sfcode_node_modules_bonjour_README_autotoc_md4255}
\hypertarget{md_sfcode_node_modules_bonjour_README_autotoc_md4256}{}\doxysubsection{Initializing}\label{md_sfcode_node_modules_bonjour_README_autotoc_md4256}

\begin{DoxyCode}{0}
\DoxyCodeLine{var bonjour = require('bonjour')([options]) }

\end{DoxyCode}


The {\ttfamily options} are optional and will be used when initializing the underlying multicast-\/dns server. For details see \href{https://github.com/mafintosh/multicast-dns\#mdns--multicastdnsoptions}{\texttt{ the multicast-\/dns documentation}}.\hypertarget{md_sfcode_node_modules_bonjour_README_autotoc_md4257}{}\doxysubsection{Publishing}\label{md_sfcode_node_modules_bonjour_README_autotoc_md4257}
\hypertarget{md_sfcode_node_modules_bonjour_README_autotoc_md4258}{}\doxysubsubsection{$<$tt$>$var service = bonjour.\+publish(options)$<$/tt$>$}\label{md_sfcode_node_modules_bonjour_README_autotoc_md4258}
Publishes a new service.

Options are\+:


\begin{DoxyItemize}
\item {\ttfamily name} (string)
\item {\ttfamily host} (string, optional) -\/ defaults to local hostname
\item {\ttfamily port} (number)
\item {\ttfamily type} (string)
\item {\ttfamily subtypes} (array of strings, optional)
\item {\ttfamily protocol} (string, optional) -\/ {\ttfamily udp} or {\ttfamily tcp} (default)
\item {\ttfamily txt} (object, optional) -\/ a key/value object to broadcast as the TXT record
\end{DoxyItemize}

IANA maintains a \href{http://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml}{\texttt{ list of official service types and port numbers}}.\hypertarget{md_sfcode_node_modules_bonjour_README_autotoc_md4259}{}\doxysubsubsection{$<$tt$>$bonjour.\+unpublish\+All(\mbox{[}callback\mbox{]})$<$/tt$>$}\label{md_sfcode_node_modules_bonjour_README_autotoc_md4259}
Unpublish all services. The optional {\ttfamily callback} will be called when the services have been unpublished.\hypertarget{md_sfcode_node_modules_bonjour_README_autotoc_md4260}{}\doxysubsubsection{$<$tt$>$bonjour.\+destroy()$<$/tt$>$}\label{md_sfcode_node_modules_bonjour_README_autotoc_md4260}
Destroy the mdns instance. Closes the udp socket.\hypertarget{md_sfcode_node_modules_bonjour_README_autotoc_md4261}{}\doxysubsection{Browser}\label{md_sfcode_node_modules_bonjour_README_autotoc_md4261}
\hypertarget{md_sfcode_node_modules_bonjour_README_autotoc_md4262}{}\doxysubsubsection{$<$tt$>$var browser = bonjour.\+find(options\mbox{[}, onup\mbox{]})$<$/tt$>$}\label{md_sfcode_node_modules_bonjour_README_autotoc_md4262}
Listen for services advertised on the network. An optional callback can be provided as the 2nd argument and will be added as an event listener for the {\ttfamily up} event.

Options (all optional)\+:


\begin{DoxyItemize}
\item {\ttfamily type} (string)
\item {\ttfamily subtypes} (array of strings)
\item {\ttfamily protocol} (string) -\/ defaults to {\ttfamily tcp}
\item {\ttfamily txt} (object) -\/ passed into \href{https://github.com/watson/dns-txt}{\texttt{ dns-\/txt module}} contructor. Set to {\ttfamily \{ binary\+: true \}} if you want to keep the TXT records in binary
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_bonjour_README_autotoc_md4263}{}\doxysubsubsection{$<$tt$>$var browser = bonjour.\+find\+One(options\mbox{[}, callback\mbox{]})$<$/tt$>$}\label{md_sfcode_node_modules_bonjour_README_autotoc_md4263}
Listen for and call the {\ttfamily callback} with the first instance of a service matching the {\ttfamily options}. If no {\ttfamily callback} is given, it\textquotesingle{}s expected that you listen for the {\ttfamily up} event. The returned {\ttfamily browser} will automatically stop it self after the first matching service.

Options are the same as given in the {\ttfamily browser.\+find} function.\hypertarget{md_sfcode_node_modules_bonjour_README_autotoc_md4264}{}\doxysubsubsection{$<$tt$>$\+Event\+: up$<$/tt$>$}\label{md_sfcode_node_modules_bonjour_README_autotoc_md4264}
Emitted every time a new service is found that matches the browser.\hypertarget{md_sfcode_node_modules_bonjour_README_autotoc_md4265}{}\doxysubsubsection{$<$tt$>$\+Event\+: down$<$/tt$>$}\label{md_sfcode_node_modules_bonjour_README_autotoc_md4265}
Emitted every time an existing service emmits a goodbye message.\hypertarget{md_sfcode_node_modules_bonjour_README_autotoc_md4266}{}\doxysubsubsection{$<$tt$>$browser.\+services$<$/tt$>$}\label{md_sfcode_node_modules_bonjour_README_autotoc_md4266}
An array of services known by the browser to be online.\hypertarget{md_sfcode_node_modules_bonjour_README_autotoc_md4267}{}\doxysubsubsection{$<$tt$>$browser.\+start()$<$/tt$>$}\label{md_sfcode_node_modules_bonjour_README_autotoc_md4267}
Start looking for matching services.\hypertarget{md_sfcode_node_modules_bonjour_README_autotoc_md4268}{}\doxysubsubsection{$<$tt$>$browser.\+stop()$<$/tt$>$}\label{md_sfcode_node_modules_bonjour_README_autotoc_md4268}
Stop looking for matching services.\hypertarget{md_sfcode_node_modules_bonjour_README_autotoc_md4269}{}\doxysubsubsection{$<$tt$>$browser.\+update()$<$/tt$>$}\label{md_sfcode_node_modules_bonjour_README_autotoc_md4269}
Broadcast the query again.\hypertarget{md_sfcode_node_modules_bonjour_README_autotoc_md4270}{}\doxysubsection{Service}\label{md_sfcode_node_modules_bonjour_README_autotoc_md4270}
\hypertarget{md_sfcode_node_modules_bonjour_README_autotoc_md4271}{}\doxysubsubsection{$<$tt$>$\+Event\+: up$<$/tt$>$}\label{md_sfcode_node_modules_bonjour_README_autotoc_md4271}
Emitted when the service is up.\hypertarget{md_sfcode_node_modules_bonjour_README_autotoc_md4272}{}\doxysubsubsection{$<$tt$>$\+Event\+: error$<$/tt$>$}\label{md_sfcode_node_modules_bonjour_README_autotoc_md4272}
Emitted if an error occurrs while publishing the service.\hypertarget{md_sfcode_node_modules_bonjour_README_autotoc_md4273}{}\doxysubsubsection{$<$tt$>$service.\+stop(\mbox{[}callback\mbox{]})$<$/tt$>$}\label{md_sfcode_node_modules_bonjour_README_autotoc_md4273}
Unpublish the service. The optional {\ttfamily callback} will be called when the service have been unpublished.\hypertarget{md_sfcode_node_modules_bonjour_README_autotoc_md4274}{}\doxysubsubsection{$<$tt$>$service.\+start()$<$/tt$>$}\label{md_sfcode_node_modules_bonjour_README_autotoc_md4274}
Publish the service.\hypertarget{md_sfcode_node_modules_bonjour_README_autotoc_md4275}{}\doxysubsubsection{$<$tt$>$service.\+name$<$/tt$>$}\label{md_sfcode_node_modules_bonjour_README_autotoc_md4275}
The name of the service, e.\+g. {\ttfamily Apple TV}.\hypertarget{md_sfcode_node_modules_bonjour_README_autotoc_md4276}{}\doxysubsubsection{$<$tt$>$service.\+type$<$/tt$>$}\label{md_sfcode_node_modules_bonjour_README_autotoc_md4276}
The type of the service, e.\+g. {\ttfamily http}.\hypertarget{md_sfcode_node_modules_bonjour_README_autotoc_md4277}{}\doxysubsubsection{$<$tt$>$service.\+subtypes$<$/tt$>$}\label{md_sfcode_node_modules_bonjour_README_autotoc_md4277}
An array of subtypes. Note that this property might be {\ttfamily null}.\hypertarget{md_sfcode_node_modules_bonjour_README_autotoc_md4278}{}\doxysubsubsection{$<$tt$>$service.\+protocol$<$/tt$>$}\label{md_sfcode_node_modules_bonjour_README_autotoc_md4278}
The protocol used by the service, e.\+g. {\ttfamily tcp}.\hypertarget{md_sfcode_node_modules_bonjour_README_autotoc_md4279}{}\doxysubsubsection{$<$tt$>$service.\+host$<$/tt$>$}\label{md_sfcode_node_modules_bonjour_README_autotoc_md4279}
The hostname or ip address where the service resides.\hypertarget{md_sfcode_node_modules_bonjour_README_autotoc_md4280}{}\doxysubsubsection{$<$tt$>$service.\+port$<$/tt$>$}\label{md_sfcode_node_modules_bonjour_README_autotoc_md4280}
The port on which the service listens, e.\+g. {\ttfamily 5000}.\hypertarget{md_sfcode_node_modules_bonjour_README_autotoc_md4281}{}\doxysubsubsection{$<$tt$>$service.\+fqdn$<$/tt$>$}\label{md_sfcode_node_modules_bonjour_README_autotoc_md4281}
The fully qualified domain name of the service. E.\+g. if given the name {\ttfamily Foo Bar}, the type {\ttfamily http} and the protocol {\ttfamily tcp}, the {\ttfamily service.\+fqdn} property will be {\ttfamily Foo Bar.\+\_\+http.\+\_\+tcp.\+local}.\hypertarget{md_sfcode_node_modules_bonjour_README_autotoc_md4282}{}\doxysubsubsection{$<$tt$>$service.\+txt$<$/tt$>$}\label{md_sfcode_node_modules_bonjour_README_autotoc_md4282}
The TXT record advertised by the service (a key/value object). Note that this property might be {\ttfamily null}.\hypertarget{md_sfcode_node_modules_bonjour_README_autotoc_md4283}{}\doxysubsubsection{$<$tt$>$service.\+published$<$/tt$>$}\label{md_sfcode_node_modules_bonjour_README_autotoc_md4283}
A boolean indicating if the service is currently published.\hypertarget{md_sfcode_node_modules_bonjour_README_autotoc_md4284}{}\doxysection{License}\label{md_sfcode_node_modules_bonjour_README_autotoc_md4284}
MIT 