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

Asked

Viewed 55 times

0

The problem I am encountering is that I am not being able to delete a dns-sd service from the local network. With the Registerseservice method the dns-sd service is created correctly, but I do not know how to delete that same service from the local network, ie the Unregisterservice method is not working. I would appreciate your help in this 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 end 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");

        }

    }
  • Welcome to sopt. Can you edit the question and make the problem clearer? honestly I didn’t understand anything.

  • Thank you for the comment, I think that this is more noticeable.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.