2 This file is part of avahi.
4 avahi is free software; you can redistribute it and/or modify it
5 under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
9 avahi is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
12 Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with avahi; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
25 public class AvahiTest {
26 private static Client client;
28 public static void Main () {
29 client = new Client ();
31 EntryGroup eg = new EntryGroup (client);
32 eg.StateChanged += OnEntryGroupChanged;
33 eg.AddService ("foobar2", "_daap._tcp", client.DomainName,
34 444, new string[] { "foo", "bar", "baz" });
40 private static void OnEntryGroupChanged (object o, EntryGroupState state)
42 Console.WriteLine ("Entry group status: " + state);
44 if (state == EntryGroupState.Established) {
45 DomainBrowser browser = new DomainBrowser (client);
46 browser.DomainAdded += OnDomainAdded;
50 private static void OnDomainAdded (object o, DomainInfo info)
52 Console.WriteLine ("Got domain added: " + info.Domain);
53 ServiceTypeBrowser stb = new ServiceTypeBrowser (client, info.Domain);
54 stb.ServiceTypeAdded += OnServiceTypeAdded;
57 private static void OnServiceTypeAdded (object o, ServiceTypeInfo info)
59 Console.WriteLine ("Got service type: " + info.ServiceType);
60 ServiceBrowser sb = new ServiceBrowser (client, info.ServiceType, info.Domain);
61 sb.ServiceAdded += OnServiceAdded;
64 private static void OnServiceAdded (object o, ServiceInfo info)
66 // Console.WriteLine ("Got service: " + info.Name);
67 ServiceResolver resolver = new ServiceResolver (client, info);
68 resolver.Found += OnServiceResolved;
71 private static void OnServiceResolved (object o, ServiceInfo info)
73 Console.WriteLine ("Service '{0}' at {1}:{2}", info.Name, info.Host, info.Port);
74 AddressResolver ar = new AddressResolver (client, info.Address);
75 ar.Found += OnAddressResolved;
78 private static void OnAddressResolved (object o, string host, IPAddress address)
80 Console.WriteLine ("Resolved {0} to {1}", address, host);
81 HostNameResolver hr = new HostNameResolver (client, host);
82 hr.Found += OnHostNameResolved;
85 private static void OnHostNameResolved (object o, string host, IPAddress address)
87 Console.WriteLine ("Resolved {0} to {1}", host, address);