package service import ( "fmt" "log" "time" "git.cliffbreak.de/Cliffbreak/tsviewer/config" ts3 "github.com/multiplay/go-ts3" ) type Service struct { TSClient *ts3.Client } func New(config config.Config) (*Service, error) { client, err := ts3.NewClient(fmt.Sprintf("%s:%d", config.ServerTS.IP, config.ServerTS.PortQuery)) if err != nil { return nil, err } if err := client.Login(config.User.Name, config.User.Password); err != nil { return nil, err } if err := client.UsePort(int(config.ServerTS.PortServer)); err != nil { return nil, err } if err := client.SetNick(config.User.Nickname); err != nil { return nil, err } go func() { for true { time.Sleep(time.Second * 150) client.Server.Version() log.Println("keep alive") } }() return &Service{ TSClient: client, }, nil }