diff options
author | Christian Pointner <equinox@spreadspace.org> | 2019-02-13 23:30:46 +0100 |
---|---|---|
committer | Christian Pointner <equinox@spreadspace.org> | 2019-02-13 23:30:46 +0100 |
commit | 4f59f43e0184c32243fae35f5aa2e52c9f5a7b48 (patch) | |
tree | 8deeb158e848569757eef8a8424c2903eb59f349 /cmd | |
parent | basic infrastructure for dolmetschctl (diff) |
actually send switch language commands
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/dolmetschctl/dolmetschctl.go | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/cmd/dolmetschctl/dolmetschctl.go b/cmd/dolmetschctl/dolmetschctl.go index fb8cdf3..bfe9a92 100644 --- a/cmd/dolmetschctl/dolmetschctl.go +++ b/cmd/dolmetschctl/dolmetschctl.go @@ -84,7 +84,21 @@ func run(ctrl *controller.Controller, ws *websocket.Conn) error { if !ok { return fmt.Errorf("controller channel was closed.") } - log.Printf("got controller event: %v", ev) + if ev.Type != controller.ButtonPressed { + continue + } + lang := "" + switch ev.Button { + case 0: + lang = "en" + case 1: + lang = "de" + default: + lang = "none" + } + if err := ws.WriteJSON(types.WebSocketRequest{Command: "language", Args: []string{lang}}); err != nil { + return err + } case msg, ok := <-wsCh: if !ok { return fmt.Errorf("websocket channel was closed.") |