master
bel 2023-03-26 08:44:30 -06:00
parent fbded57807
commit a3650642ca
2 changed files with 28 additions and 19 deletions

View File

@ -13,6 +13,10 @@ func (v01 *V01) listen() {
if v01.cfg.Feedback.Addr == "" {
return
}
return v01._listen()
}
func (v01 *V01) _listen() {
mutex := &sync.RWMutex{}
s := &http.Server{
Addr: v01.cfg.Feedback.Addr,
@ -24,6 +28,22 @@ func (v01 *V01) listen() {
mutex.Lock()
defer mutex.Unlock()
}
v01.ServeHTTP(w, r)
}),
}
go func() {
<-v01.ctx.Done()
log.Println("closing v01 server")
s.Close()
}()
log.Println("starting v01 server")
if err := s.ListenAndServe(); err != nil && v01.ctx.Err() == nil {
log.Println("err with v01 server", err)
panic(err)
}
}
func (v01 *V01) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if r.Method == http.MethodGet {
r = r.WithContext(v01.ctx)
user, ok := v01.cfg.Users[r.URL.Query().Get("user")]
@ -43,16 +63,4 @@ func (v01 *V01) listen() {
default:
}
}
}),
}
go func() {
<-v01.ctx.Done()
log.Println("closing v01 server")
s.Close()
}()
log.Println("starting v01 server")
if err := s.ListenAndServe(); err != nil && v01.ctx.Err() == nil {
log.Println("err with v01 server", err)
panic(err)
}
}

View File

@ -1,4 +1,5 @@
todo:
- https via home.blapointe and rproxy
- tts for when someone said the word via larynx docker + http.get + https://pkg.go.dev/github.com/faiface/beep@v1.1.0/wav
- endpoint for v01 to start read-only mode so when hotword spoken, players are dcd
without losing players; press a hotkey that is bound to dolphin emulator pause