Files
pmomusic/internal/ssdp/ssdp.go
Eric Coissac 2a8bba25a1 Changes to be committed:
modified:   cmd/pmomusic/main.go
	modified:   go.mod
	modified:   go.sum
	modified:   internal/ssdp/responder.go
	modified:   internal/ssdp/ssdp.go
	new file:   internal/ssdp/uuid.go
	renamed:    internal/upnp/http.go -> internal/upnp/description_xml.go
	modified:   internal/upnp/device.go
	renamed:    web/index.html -> internal/upnp/html/index.html
	modified:   internal/upnp/server.go
	modified:   internal/upnp/service.go
	new file:   internal/upnp/xml/Info.xml
	new file:   internal/upnp/xml/Playlist.xml
	new file:   internal/upnp/xml/Product.xml
2025-06-08 21:39:58 +02:00

36 lines
850 B
Go

package ssdp
import (
"log"
"strconv"
"time"
"gargoton.petite-maison-orange.fr/eric/pmomusic/internal/upnp"
"github.com/koron/go-ssdp"
)
func AnnounceRenderer(device *upnp.DeviceDescription) {
st := "urn:schemas-upnp-org:device:MediaRenderer:1"
server := "pmomusic/1.0 UPnP/1.1 DLNARenderer/1.0"
maxAge := 1800
_, err := ssdp.Advertise(st, device.USN+"::"+st, device.IP+":"+strconv.Itoa(int(device.Port)), server, maxAge)
if err != nil {
log.Println("SSDP advertise error:", err)
return
}
log.Println("✅ SSDP advertisement started")
// Ce `Advertiser` fait automatiquement le NOTIFY loop.
// Il est censé continuer à diffuser les `alive` tous les MaxAge / 2.
// Exemple : on attend indéfiniment
for {
time.Sleep(time.Hour)
}
// Un jour on voudra faire ça à l'arrêt :
// adv.Close() // envoie le ssdp:byebye
}