private static NetworkService ParseServiceInfo (ServiceInfo info) { Uri uri = new Uri (String.Format ("http://{0}:{1}", info.HostName, info.Port)); bool password_required = false; string cookie = null; // Check if the network service is password protected // and store cookie when found foreach (byte[] bytes in info.Text) { string text = System.Text.Encoding.UTF8.GetString (bytes); string [] split = text.Split ('='); if (split.Length < 2) continue; if (split [0].ToLower () == "password") { password_required = (split [1].ToLower () == "true"); } else if (split [0].ToLower () == "org.freedesktop.avahi.cookie") { cookie = split [1]; } } NetworkService service = new NetworkService (info.Name, uri, password_required, cookie); return service; }
public ServiceResolver(Client client, ServiceInfo service) : this(client, service.NetworkInterface, service.Protocol, service.Name, service.ServiceType, service.Domain, Protocol.Unspecified, GetLookupFlags (service.Flags)) { }
public Service(AV.ServiceInfo service) { this.service = service; }
private void OnServiceResolverCallback(IntPtr resolver, int iface, Protocol proto, ResolverEvent revent, IntPtr name, IntPtr type, IntPtr domain, IntPtr host, IntPtr address, UInt16 port, IntPtr txt, LookupResultFlags flags, IntPtr userdata) { ServiceInfo info; info.NetworkInterface = iface; info.Protocol = proto; info.Domain = Utility.PtrToString (domain); info.ServiceType = Utility.PtrToString (type); info.Name = Utility.PtrToString (name); info.HostName = Utility.PtrToString (host); info.Address = Utility.PtrToAddress (address); info.Port = port; ArrayList txtlist = new ArrayList (); for (IntPtr l = txt; l != IntPtr.Zero; l = avahi_string_list_get_next (l)) { IntPtr buf = avahi_string_list_get_text (l); int len = avahi_string_list_get_size (l); byte[] txtbuf = new byte[len]; Marshal.Copy (buf, txtbuf, 0, len); txtlist.Add (txtbuf); } info.Text = (byte[][]) txtlist.ToArray (typeof (byte[])); info.Flags = flags; switch (revent) { case ResolverEvent.Found: currentInfo = info; foreach (ServiceInfoHandler handler in foundListeners) handler (this, new ServiceInfoArgs (info)); break; case ResolverEvent.Failure: EmitFailure (client.LastError); break; } }
public ServiceInfoArgs(ServiceInfo service) { this.service = service; }
public ResolvableService(AV.Client client, AV.ServiceInfo service) : base(service) { this.client = client; }