[UWP] [C #] How to stop the announcement of a service on the local network (unregisterService in android) with the Windows API.Networking.ServiceDiscovery.Dnssd

0

The problem I have is that I can not delete a dns-sd service from the local network. With the RegisterService method the dns-sd service is created correctly, but I do not know how to do this to eliminate this same service from the local network, that is the UnregisterService method is not working. I would appreciate any help in that regard.

  public async void RegisterService(WFIDnsServiceInfo dnsServiceInfo)
  {
     listener = getListener();
     await listener.BindServiceNameAsync("");
     dnssdServiceInstance = String.Format("{0}.{1}local", dnsServiceInfo.getServiceName(), dnsServiceInfo.getServiceType());
        listenServ = new DnssdServiceInstance(dnssdServiceInstance, null, 0);
        try
        {
            var result = await listenServ.RegisterStreamSocketListenerAsync(listener); 

            Log.LogMensage(this.GetType().Name, Log.Level.LevelInfo, "Serviço criado com sucesso!!!");

            //Serviço registado com sucesso
            getDelegate().onServiceRegistered(dnsServiceInfo);
        }
        catch (Exception exp)
        {
            Log.LogMensage(this.GetType().Name, Log.Level.LevelInfo, "Erro ao criar o serviço");

        }
    }

And the method to terminate the service announcement is as follows (does not work):

     public async void UnregisterService()
    {           
        Log.LogMensage(this.GetType().Name, Log.Level.LevelInfo, "UnregisterService!!!!");
        try
        {
            getListener().Dispose();
        }
        catch (Exception exp)
        {
            Log.LogMensage(this.GetType().Name, Log.Level.LevelInfo, "Erro fechar serviço");

        }

    }
    
asked by anonymous 10.05.2016 / 22:53

0 answers