run o.Listen() in goroutine.

run main thread for 30 seconds
This commit is contained in:
onyx-and-iris 2022-12-09 00:55:18 +00:00
parent a846c59e72
commit 632cd9049f

View File

@ -2,6 +2,7 @@ package main
import ( import (
"fmt" "fmt"
"time"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
@ -16,8 +17,7 @@ type observer struct {
// newObserver returns an observer type // newObserver returns an observer type
func newObserver(vm *voicemeeter.Remote) *observer { func newObserver(vm *voicemeeter.Remote) *observer {
o := &observer{vm, make(chan string)} return &observer{vm, make(chan string)}
return o
} }
// OnUpdate satisfies the observer interface defined in publisher.go // OnUpdate satisfies the observer interface defined in publisher.go
@ -49,7 +49,7 @@ func init() {
func runObserver(vm *voicemeeter.Remote) { func runObserver(vm *voicemeeter.Remote) {
o := newObserver(vm) o := newObserver(vm)
o.Listen() go o.Listen()
} }
// main connects to Voiceemeter, registers observer for updates // main connects to Voiceemeter, registers observer for updates
@ -62,6 +62,8 @@ func main() {
defer vm.Logout() defer vm.Logout()
runObserver(vm) runObserver(vm)
time.Sleep(time.Duration(30) * time.Second)
} }
// vmConnect connects to Voicemeeter potato and logs into the API // vmConnect connects to Voicemeeter potato and logs into the API