diff --git a/src/device/input/parse/v01/server.go b/src/device/input/parse/v01/server.go index 978c876..160f201 100644 --- a/src/device/input/parse/v01/server.go +++ b/src/device/input/parse/v01/server.go @@ -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,25 +28,7 @@ func (v01 *V01) listen() { mutex.Lock() defer mutex.Unlock() } - if r.Method == http.MethodGet { - r = r.WithContext(v01.ctx) - user, ok := v01.cfg.Users[r.URL.Query().Get("user")] - if !ok { - user = v01.cfg.Users["broadcast"] - } - w.Write([]byte(user.Message)) - } else if r.URL.Path == "/broadcast" { - b, _ := io.ReadAll(r.Body) - v := v01.cfg.Users["broadcast"] - v.Message = string(b) - v01.cfg.Users["broadcast"] = v - } - if _, ok := r.URL.Query()["refresh"]; ok { - select { - case wrap.ChSigUsr1 <- syscall.SIGUSR1: - default: - } - } + v01.ServeHTTP(w, r) }), } go func() { @@ -56,3 +42,25 @@ func (v01 *V01) listen() { 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")] + if !ok { + user = v01.cfg.Users["broadcast"] + } + w.Write([]byte(user.Message)) + } else if r.URL.Path == "/broadcast" { + b, _ := io.ReadAll(r.Body) + v := v01.cfg.Users["broadcast"] + v.Message = string(b) + v01.cfg.Users["broadcast"] = v + } + if _, ok := r.URL.Query()["refresh"]; ok { + select { + case wrap.ChSigUsr1 <- syscall.SIGUSR1: + default: + } + } +} diff --git a/todo.yaml b/todo.yaml index 26c7fd3..8cd5d8f 100755 --- a/todo.yaml +++ b/todo.yaml @@ -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