2015-06-07 11:28:34 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
|
2022-11-01 19:02:13 +00:00
|
|
|
"git.cyrilix.bzh/cyrilix/goupnp/ssdp"
|
2015-06-07 11:28:34 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
c := make(chan ssdp.Update)
|
|
|
|
srv, reg := ssdp.NewServerAndRegistry()
|
|
|
|
reg.AddListener(c)
|
|
|
|
go listener(c)
|
|
|
|
if err := srv.ListenAndServe(); err != nil {
|
|
|
|
log.Print("ListenAndServe failed: ", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func listener(c <-chan ssdp.Update) {
|
|
|
|
for u := range c {
|
|
|
|
if u.Entry != nil {
|
|
|
|
log.Printf("Event: %v USN: %s Entry: %#v", u.EventType, u.USN, *u.Entry)
|
|
|
|
} else {
|
|
|
|
log.Printf("Event: %v USN: %s Entry: <nil>", u.EventType, u.USN)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|