func TestIssue_4(t *testing.T) { log.SetFlags(log.Ltime | log.Lshortfile) log.Printf("Discovery: Starting") mgr, err := sonos.Discover("eth0", "13104") if nil != err { panic(err) } log.Printf("Discovery: Done; Reactor: Starting") reactor := sonos.MakeReactor("eth0", "13106") go read_events(reactor.Channel()) ///// <------------ log.Printf("Reactor: Running; Query: Starting") qry := ssdp.ServiceQueryTerms{ ssdp.ServiceKey(sonos.MUSIC_SERVICES): -1, } res := mgr.QueryServices(qry) log.Printf("Query: Done; Connect: Starting") if dev_list, has := res[sonos.MUSIC_SERVICES]; has { for _, dev := range dev_list { if sonos.SONOS == dev.Product() { if _, err := upnp.Describe(dev.Location()); nil != err { panic(err) } else { sonos.Connect(dev, reactor, sonos.SVC_ALL) log.Printf("Connect: Done") break } } } } }
func ConnectReciva(dev ssdp.Device, reactor upnp.Reactor, flags int) (reciva *Reciva) { if svc_map, err := upnp.Describe(dev.Location()); nil != err { panic(err) } else { reciva = MakeReciva(svc_map, reactor, flags) } return }
func Connect(dev ssdp.Device, reactor upnp.Reactor, flags int) (sonos *Sonos) { if svc_map, err := upnp.Describe(dev.Location()); nil != err { panic(err) } else { sonos = MakeSonos(svc_map, reactor, flags) } return }
func ConnectAnyReciva(mgr ssdp.Manager, reactor upnp.Reactor, flags int) (reciva []*Reciva) { qry := ssdp.ServiceQueryTerms{ ssdp.ServiceKey(RECIVA_RADIO): -1, } res := mgr.QueryServices(qry) if dev_list, has := res[RECIVA_RADIO]; has { for _, dev := range dev_list { if RADIO == dev.Product() { if svc_map, err := upnp.Describe(dev.Location()); nil != err { panic(err) } else { reciva = append(reciva, MakeReciva(svc_map, reactor, flags)) } break } } } return }
func ConnectAny(mgr ssdp.Manager, reactor upnp.Reactor, flags int) (sonos []*Sonos) { qry := ssdp.ServiceQueryTerms{ ssdp.ServiceKey(MUSIC_SERVICES): -1, } res := mgr.QueryServices(qry) if dev_list, has := res[MUSIC_SERVICES]; has { for _, dev := range dev_list { if SONOS == dev.Product() { if svc_map, err := upnp.Describe(dev.Location()); nil != err { panic(err) } else { sonos = append(sonos, MakeSonos(svc_map, reactor, flags)) } break } } } return }