go package to browse Plex server / players with GDM.
func GetPlayers() ([]*GDMMessage, error)
func GetPlayer(name string) (*GDMMessage, error)
func GetServers() ([]*GDMMessage, error)
func GetServer(name string) (*GDMMessage, error)
func WatchPlayers(freq int) (chan *GDMWatcher, error)
func WatchPlayer(name string) (chan *GDMWatcher, error)
func WatchServers(freq int) (chan *GDMWatcher, error)
func WatchServer(name string) (chan *GDMWatcher, error)
type GDMMessage struct {
Address *net.UDPAddr
Added bool
Props map[string]string
}
type GDMWatcher struct {
Watch chan *GDMMessage
closer chan bool
}
func (w *GDMWatcher) Close()
box, err := gdm.GetServer("someName")
if err != nil {
fmt.Println(err.Error())
} else {
fmt.Printf("%# v\n", box.Props["Name"])
}
w, cerr := gdm.WatchServers(5)
if cerr != nil {
// Error handling
} else {
i := 0
fmt.Printf("%# v\n", w)
fmt.Println("================")
for gdm := range w.Watch {
fmt.Printf("%02d ++++++++++++++\n", i)
fmt.Printf("%# v\n", gdm)
i++
if i >= 10 {
w.Close() // Call close to quit to clean up.
}
}
}