Mono.Zeroconf.RegisterService.Register C# (CSharp) Méthode

Register() public méthode

public Register ( ) : void
Résultat void
        public void Register()
        {
            register_service.Register();
        }

Usage Example

        /// <summary>
        /// Start new broadcast service
        /// </summary>
        /// <param name="type">Type of discovery</param>
        /// <param name="nameToBroadcast">The name of the service that needs to be broadcasted</param>
        /// <param name="physicalLocation">The physical location of the service that needs to be broadcasted</param>
        /// <param name="addressToBroadcast">The address of the service that needs to be broadcasted</param>
        /// <param name="broadcastPort">The port of the broadcast service. Default=56789</param>
        public void Start(DiscoveryType type,string nameToBroadcast,string physicalLocation,string code,Uri addressToBroadcast,int broadcastPort=7892)
        {
            DiscoveryType = type;

            switch (DiscoveryType)
            {
                case DiscoveryType.WSDiscovery:
                    {
                        Ip = Net.GetIp(IPType.All);
                        Port = broadcastPort;
                        Address = "http://" + Ip + ":" + Port + "/";

                        _discoveryHost = new ServiceHost(new DiscoveyService());

                        var serviceEndpoint = _discoveryHost.AddServiceEndpoint(typeof(IDiscovery), new WebHttpBinding(), 
                                                                                Net.GetUrl(Ip, Port, ""));
                        serviceEndpoint.Behaviors.Add(new WebHttpBehavior());

                        var broadcaster = new EndpointDiscoveryBehavior();

                        broadcaster.Extensions.Add(nameToBroadcast.ToXElement<string>());
                        broadcaster.Extensions.Add(physicalLocation.ToXElement<string>());
                        broadcaster.Extensions.Add(addressToBroadcast.ToString().ToXElement<string>());
                        broadcaster.Extensions.Add(code.ToXElement<string>());

                        serviceEndpoint.Behaviors.Add(broadcaster);
                        _discoveryHost.Description.Behaviors.Add(new ServiceDiscoveryBehavior());
                        _discoveryHost.Description.Endpoints.Add(new UdpDiscoveryEndpoint());
                        _discoveryHost.Open();

                        IsRunning = true;
                    }
                    break;
                case DiscoveryType.Zeroconf:
                    {
                        var service = new RegisterService
                                          {Name = nameToBroadcast, RegType = "_am._tcp", ReplyDomain = "local.", Port = 3689};

                        // TxtRecords are optional
                        var txtRecord = new TxtRecord(){
                                                {"name", nameToBroadcast},
                                                {"addr", addressToBroadcast.ToString()},
                                                {"loc", physicalLocation},
                                                {"code", code}
                                            };
                        service.TxtRecord = txtRecord;

                        service.Register();
                    }
                    break;
            }
        }
All Usage Examples Of Mono.Zeroconf.RegisterService::Register