Exemplo n.º 1
0
func MakeReciva(svc_map upnp.ServiceMap, reactor upnp.Reactor, flags int) (reciva *Reciva) {
	reciva = &Reciva{}
	for svc_type, svc_list := range svc_map {
		switch svc_type {
		case "AVTransport":
			for _, svc := range svc_list {
				reciva.AVTransport.Svc = svc
				svc.Describe()
				if nil != reactor {
					reactor.Subscribe(svc, &reciva.AVTransport)
				}
				break
			}
		case "ConnectionManager":
			for _, svc := range svc_list {
				reciva.ConnectionManager.Svc = svc
				svc.Describe()
				if nil != reactor {
					reactor.Subscribe(svc, &reciva.ConnectionManager)
				}
				break
			}
		case "Playlist":
			for _, svc := range svc_list {
				reciva.Playlist.Svc = svc
				svc.Describe()
				if nil != reactor {
					reactor.Subscribe(svc, &reciva.Playlist)
				}
				break
			}
		case "RecivaRadio":
			for _, svc := range svc_list {
				reciva.RecivaRadio.Svc = svc
				svc.Describe()
				if nil != reactor {
					reactor.Subscribe(svc, &reciva.RecivaRadio)
				}
				break
			}
		case "RecivaSimpleRemote":
			for _, svc := range svc_list {
				reciva.RecivaSimpleRemote.Svc = svc
				svc.Describe()
				if nil != reactor {
					reactor.Subscribe(svc, &reciva.RecivaSimpleRemote)
				}
				break
			}
		case "RenderingControl":
			for _, svc := range svc_list {
				reciva.RenderingControl.Svc = svc
				svc.Describe()
				if nil != reactor {
					reactor.Subscribe(svc, &reciva.RenderingControl)
				}
				break
			}
		}
	}
	return
}
Exemplo n.º 2
0
Arquivo: sonos.go Projeto: bb/go-sonos
func MakeSonos(svc_map upnp.ServiceMap, reactor upnp.Reactor, flags int) (sonos *Sonos) {
	sonos = &Sonos{}
	for svc_type, svc_list := range svc_map {
		if !sonosCheckServiceFlags(svc_type, flags) {
			continue
		}
		switch svc_type {
		case "AlarmClock":
			for _, svc := range svc_list {
				sonos.AlarmClock.Svc = svc
				svc.Describe()
				reactor.Subscribe(svc, sonosHandleUpdate)
				break
			}
		case "AVTransport":
			for _, svc := range svc_list {
				sonos.AVTransport.Svc = svc
				svc.Describe()
				reactor.Subscribe(svc, sonosHandleUpdate)
				break
			}
		case "ConnectionManager":
			for _, svc := range svc_list {
				sonos.ConnectionManager.Svc = svc
				svc.Describe()
				reactor.Subscribe(svc, sonosHandleUpdate)
				break
			}
		case "ContentDirectory":
			for _, svc := range svc_list {
				sonos.ContentDirectory.Svc = svc
				svc.Describe()
				reactor.Subscribe(svc, sonosHandleUpdate)
				break
			}
		case "DeviceProperties":
			for _, svc := range svc_list {
				sonos.DeviceProperties.Svc = svc
				svc.Describe()
				reactor.Subscribe(svc, sonosHandleUpdate)
				break
			}
		case "GroupManagement":
			for _, svc := range svc_list {
				sonos.GroupManagement.Svc = svc
				svc.Describe()
				reactor.Subscribe(svc, sonosHandleUpdate)
				break
			}
		case "MusicServices":
			for _, svc := range svc_list {
				sonos.MusicServices.Svc = svc
				svc.Describe()
				reactor.Subscribe(svc, sonosHandleUpdate)
				break
			}
		case "RenderingControl":
			for _, svc := range svc_list {
				sonos.RenderingControl.Svc = svc
				svc.Describe()
				reactor.Subscribe(svc, sonosHandleUpdate)
				break
			}
		case "SystemProperties":
			for _, svc := range svc_list {
				sonos.SystemProperties.Svc = svc
				svc.Describe()
				reactor.Subscribe(svc, sonosHandleUpdate)
				break
			}
		case "ZoneGroupTopology":
			for _, svc := range svc_list {
				sonos.ZoneGroupTopology.Svc = svc
				svc.Describe()
				reactor.Subscribe(svc, sonosHandleUpdate)
				break
			}
		}
	}
	return
}