private int iface;
private Protocol proto;
private IPAddress address;
+ private AddressResolverCallback cb;
private IPAddress currentAddress;
private string currentHost;
this.iface = iface;
this.proto = proto;
this.address = address;
+ cb = OnAddressResolverCallback;
}
~AddressResolver ()
IntPtr addrPtr = Utility.StringToPtr (address.ToString ());
handle = avahi_address_resolver_new (client.Handle, iface, proto, addrPtr,
- OnAddressResolverCallback, IntPtr.Zero);
+ cb, IntPtr.Zero);
Utility.Free (addrPtr);
}
private static void OnServiceResolved (object o, ServiceInfo info)
{
- Console.WriteLine ("Service '{0}' at {1}:{2}", info.Name, info.Host, info.Port);
+ Console.WriteLine ("Service '{0}' at {1}:{2}", info.Name, info.HostName, info.Port);
foreach (byte[] bytes in info.Text) {
Console.WriteLine ("Text: " + Encoding.UTF8.GetString (bytes));
}
Removed
}
- internal delegate void ClientHandler (IntPtr client, ClientState state, IntPtr userData);
+ internal delegate void ClientCallback (IntPtr client, ClientState state, IntPtr userData);
+
+ public delegate void ClientStateHandler (object o, ClientState state);
public enum Protocol {
Unspecified = 0,
private IntPtr handle;
[DllImport ("avahi-client")]
- private static extern IntPtr avahi_client_new (IntPtr poll, ClientHandler handler,
+ private static extern IntPtr avahi_client_new (IntPtr poll, ClientCallback handler,
IntPtr userData, out int error);
[DllImport ("avahi-client")]
[DllImport ("avahi-glib")]
private static extern IntPtr avahi_glib_poll_get (IntPtr gpoll);
+ public event ClientStateHandler StateChanged;
+
internal IntPtr Handle
{
get { return handle; }
private void OnClientCallback (IntPtr client, ClientState state, IntPtr userData)
{
- Console.WriteLine ("Got new state: " + state);
+ if (StateChanged != null)
+ StateChanged (this, state);
}
}
}
private Protocol proto;
private string domain;
private DomainBrowserType btype;
+ private DomainBrowserCallback cb;
private ArrayList addListeners = new ArrayList ();
private ArrayList removeListeners = new ArrayList ();
this.proto = proto;
this.domain = domain;
this.btype = btype;
+ cb = OnDomainBrowserCallback;
}
~DomainBrowser ()
IntPtr domainPtr = Utility.StringToPtr (domain);
handle = avahi_domain_browser_new (client.Handle, iface, (int) proto, domainPtr, (int) btype,
- OnDomainBrowserCallback, IntPtr.Zero);
+ cb, IntPtr.Zero);
Utility.Free (domainPtr);
}
private Protocol proto;
private string hostname;
private Protocol aproto;
+ private HostNameResolverCallback cb;
private IPAddress currentAddress;
private string currentHost;
this.proto = proto;
this.hostname = hostname;
this.aproto = aproto;
+ cb = OnHostNameResolverCallback;
}
~HostNameResolver ()
public string ServiceType;
public string Name;
- public string Host;
+ public string HostName;
public IPAddress Address;
public UInt16 Port;
public byte[][] Text;
private Protocol proto;
private string domain;
private string type;
+ private ServiceBrowserCallback cb;
private ArrayList addListeners = new ArrayList ();
private ArrayList removeListeners = new ArrayList ();
this.proto = proto;
this.domain = domain;
this.type = type;
-
-
+ cb = OnServiceBrowserCallback;
}
~ServiceBrowser ()
IntPtr domainPtr = Utility.StringToPtr (domain);
IntPtr typePtr = Utility.StringToPtr (type);
handle = avahi_service_browser_new (client.Handle, iface, (int) proto, typePtr, domainPtr,
- OnServiceBrowserCallback, IntPtr.Zero);
+ cb, IntPtr.Zero);
Utility.Free (domainPtr);
Utility.Free (typePtr);
}
info.Domain = Utility.PtrToString (domain);
info.ServiceType = Utility.PtrToString (type);
info.Name = Utility.PtrToString (name);
- info.Host = null;
+ info.HostName = null;
info.Address = null;
info.Port = 0;
info.Text = null;
private string type;
private string domain;
private Protocol aproto;
+ private ServiceResolverCallback cb;
private ArrayList foundListeners = new ArrayList ();
private ArrayList timeoutListeners = new ArrayList ();
this.type = type;
this.domain = domain;
this.aproto = aproto;
-
-
+ cb = OnServiceResolverCallback;
}
~ServiceResolver ()
IntPtr typePtr = Utility.StringToPtr (type);
IntPtr domainPtr = Utility.StringToPtr (domain);
handle = avahi_service_resolver_new (client.Handle, iface, proto, namePtr, typePtr, domainPtr,
- aproto, OnServiceResolverCallback, IntPtr.Zero);
+ aproto, cb, IntPtr.Zero);
Utility.Free (namePtr);
Utility.Free (typePtr);
Utility.Free (domainPtr);
info.Domain = Utility.PtrToString (domain);
info.ServiceType = Utility.PtrToString (type);
info.Name = Utility.PtrToString (name);
- info.Host = Utility.PtrToString (host);
+ info.HostName = Utility.PtrToString (host);
info.Address = Utility.PtrToAddress (address);
info.Port = port;
private int iface;
private Protocol proto;
private string domain;
+ private ServiceTypeBrowserCallback cb;
private ArrayList addListeners = new ArrayList ();
private ArrayList removeListeners = new ArrayList ();
this.iface = iface;
this.proto = proto;
this.domain = domain;
+ cb = OnServiceTypeBrowserCallback;
}
~ServiceTypeBrowser ()
IntPtr domainPtr = Utility.StringToPtr (domain);
handle = avahi_service_type_browser_new (client.Handle, iface, (int) proto, domainPtr,
- OnServiceTypeBrowserCallback, IntPtr.Zero);
+ cb, IntPtr.Zero);
Utility.Free (domainPtr);
}