Inheritance: IDisposable
Exemplo n.º 1
0
        public void Dispose()
        {
            lock (eg_mutex) {
                if (entry_group == null)
                {
                    return;
                }

                entry_group.Reset();
                entry_group.Dispose();
                entry_group = null;
            }
        }
Exemplo n.º 2
0
                public void Dispose ()
                {
			Logger.Log.Debug ("Zeroconf: Service stopped...");

			if (entry_group != null) {
				entry_group.Dispose ();
				entry_group = null;
			}

			if (client != null) {
				client.Dispose ();
				client = null;
			}
                }
    public static void Main()
    {
        client = new Client ();

        Console.WriteLine ("joined service name: " + Client.JoinServiceName ("FooBar", "_foo", "local"));

        EntryGroup eg = new EntryGroup (client);
        eg.StateChanged += OnEntryGroupChanged;
        eg.AddService ("foobar2", "_dingdong._tcp", client.DomainName,
                       444, new string[] { "foo=stuff", "bar=stuff2", "baz=stuff3" });
        eg.Commit ();
        BrowseServiceTypes ("local");
        Console.WriteLine ("Press enter to quit");
        Console.ReadLine ();
    }
Exemplo n.º 4
0
        public void Register()
        {
            lock (eg_mutex) {
                if (entry_group != null)
                {
                    entry_group.Reset();
                }
                else
                {
                    entry_group = new AV.EntryGroup(client);
                    entry_group.StateChanged += OnEntryGroupStateChanged;
                }

                try {
                    string [] rendered_txt_record = null;

                    if (txt_record != null && txt_record.Count > 0)
                    {
                        rendered_txt_record = new string[txt_record.Count];
                        for (int i = 0; i < txt_record.Count; i++)
                        {
                            TxtRecordItem item = txt_record.GetItemAt(i);
                            rendered_txt_record[i] = String.Format("{0}={1}",
                                                                   item.Key, item.ValueString);
                        }
                    }

                    entry_group.AddService(name, regtype, reply_domain, (ushort)port, rendered_txt_record);
                    entry_group.Commit();
                } catch (AV.ClientException e) {
                    if (e.ErrorCode == AV.ErrorCode.Collision && OnResponse(e.ErrorCode))
                    {
                        return;
                    }
                    else
                    {
                        throw e;
                    }
                }
            }
        }
Exemplo n.º 5
0
                private void Unpublish ()
                {
			if (entry_group == null)
				return;

                        //entry_group.Reset ();
                        entry_group.Dispose ();
			entry_group = null;
                }
Exemplo n.º 6
0
                private void Publish ()
                {
                        if (client == null)
                                client = new Client ();
                        
                        try {
				string [] args = new string [] { "Password="******"true" : "false") };
					
				if (collisions > 0)
					name += String.Format (" ({0})", collisions);
                                        
				entry_group = new EntryGroup (client);
				entry_group.AddService (name, PROTOCOL, DOMAIN, port, args);
				entry_group.StateChanged += OnEntryGroupStateChanged;
				entry_group.Commit ();                               
                        } catch (ClientException e) {
                                if (e.ErrorCode == ErrorCode.Collision) {
                                        HandleCollision ();
                                        return;
                                } else {
                                        throw;
                                }
                        } catch (Exception e) {
                                Logger.Log.Error (e, "Zeroconf: Failed to publish service - '{0}'", name);
                                // FIXME: Shutdown or unpublish the service
			}
                }
Exemplo n.º 7
0
        public void Register()
        {
            lock(eg_mutex) {
                if(entry_group != null) {
                    entry_group.Reset();
                } else {
                    entry_group = new AV.EntryGroup(client);
                    entry_group.StateChanged += OnEntryGroupStateChanged;
                }

                try {
                    string [] rendered_txt_record = null;

                    if(txt_record != null && txt_record.Count > 0) {
                        rendered_txt_record = new string[txt_record.Count];
                        for(int i = 0; i < txt_record.Count; i++) {
                            TxtRecordItem item = txt_record.GetItemAt(i);
                            rendered_txt_record[i] = String.Format("{0}={1}",
                                item.Key, item.ValueString);
                        }
                    }

                    entry_group.AddService(name, regtype, reply_domain, (ushort)port, rendered_txt_record);
                    entry_group.Commit();
                } catch(AV.ClientException e) {
                    if(e.ErrorCode == AV.ErrorCode.Collision && OnResponse(e.ErrorCode)) {
                        return;
                    } else {
                        throw e;
                    }
                }
            }
        }
Exemplo n.º 8
0
        public void Dispose()
        {
            lock(eg_mutex) {
                if(entry_group == null) {
                    return;
                }

                entry_group.Reset();
                entry_group.Dispose();
                entry_group = null;
            }
        }