Hello @Mauro Fantina
if I omit this ... the code can work correctly?
No. The WiFiDirectAdvertisementPublisher object is the object that publishes advertisements. In the sample code, you could see that all the code runs after the publisher.Start() method is called. When this method is called, it means the current device is advertising wifi and is willing to connect another wifi that comes from the advertiser which is scenario 1 in the wifi direct sample.
You could also check this video about WiFi Direct: Wi-Fi Direct and Wi-Fi Direct Services API.
Thank you.