Commit() public méthode

public Commit ( ) : void
Résultat void
    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 ();
    }
        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;
                    }
                }
            }
        }
Exemple #3
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
			}
                }