24 Commits

Author SHA1 Message Date
Bel LaPointe
9418cecdf5 pre 2023-04-09 12:00:19 -06:00
Bel LaPointe
fb5da88774 explicit ws debug 2023-04-09 11:57:45 -06:00
Bel LaPointe
39f6bc8ed9 RAW_WS_PROXY_URL=http://localhost:17071, RAW_WS=8080 to use web 2023-04-09 11:53:21 -06:00
Bel LaPointe
f3cbfa1c48 html needs /proxy 2023-04-09 11:46:06 -06:00
Bel LaPointe
444245c0f5 sh 2023-04-09 11:37:46 -06:00
Bel LaPointe
52ee1e5083 mvp control via browser 2023-04-09 11:25:51 -06:00
bel
934158b7a3 y no ui 2023-04-02 11:15:51 -06:00
bel
87e63c27df go build 2023-04-02 11:13:28 -06:00
bel
f98e417ba6 gr 2023-04-02 11:13:13 -06:00
bel
d6a7ee3db0 grrr 2023-04-02 11:11:26 -06:00
bel
b814dabfd3 gr 2023-04-02 11:10:03 -06:00
bel
0a91fc656d sh 2023-04-02 11:08:16 -06:00
bel
5c3341e260 condense status 2023-04-02 11:07:21 -06:00
bel
0903c01b9a verbose user feedback 2023-04-02 10:56:35 -06:00
bel
342e2eef93 alias formatting 2023-04-02 10:44:14 -06:00
bel
b8b076450e debug 2023-04-02 10:33:20 -06:00
bel
3bb7cad554 debug 2023-04-02 10:28:12 -06:00
bel
44ec540db3 msg 2023-04-02 09:57:43 -06:00
bel
e864f2a9f5 default /get includes broadcast message if no personal message and MySecretWord 2023-04-01 11:38:13 -06:00
bel
3c70e42819 broadcast isnt a user 2023-04-01 11:31:03 -06:00
bel
9de8c91544 export todo 2023-03-28 20:33:31 -06:00
Bel LaPointe
7f2e25458e backwards bool in main 2023-03-28 11:19:53 -06:00
bel
95810d3735 todo 2023-03-27 21:45:46 -06:00
bel
df65b1ed07 mtodo 2023-03-27 21:43:44 -06:00
16 changed files with 434 additions and 193 deletions

1
go.mod
View File

@@ -10,6 +10,7 @@ require (
require (
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/hajimehoshi/oto v0.7.1 // indirect
github.com/micmonay/keybd_event v1.1.1 // indirect
github.com/pkg/errors v0.9.1 // indirect

2
go.sum
View File

@@ -11,6 +11,8 @@ github.com/go-audio/riff v1.0.0/go.mod h1:l3cQwc85y79NQFCRB7TiPoNiaijp6q8Z0Uv38r
github.com/go-audio/wav v1.0.0/go.mod h1:3yoReyQOsiARkvPl3ERCi8JFjihzG6WhjYpZCf5zAWE=
github.com/go-yaml/yaml v2.1.0+incompatible h1:RYi2hDdss1u4YE7GwixGzWwVo47T8UQwnTLB6vQiq+o=
github.com/go-yaml/yaml v2.1.0+incompatible/go.mod h1:w2MrLa16VYP0jy6N7M5kHaCkaLENm+P+Tv+MfurjSw0=
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/hajimehoshi/go-mp3 v0.3.0/go.mod h1:qMJj/CSDxx6CGHiZeCgbiq2DSUkbK0UbtXShQcnfyMM=
github.com/hajimehoshi/oto v0.6.1/go.mod h1:0QXGEkbuJRohbJaxr7ZQSxnju7hEhseiPx2hrh6raOI=
github.com/hajimehoshi/oto v0.7.1 h1:I7maFPz5MBCwiutOrz++DLdbr4rTzBsbBuV2VpgU9kk=

View File

@@ -11,6 +11,14 @@ import (
func main() {
ctx, can := signal.NotifyContext(context.Background(), syscall.SIGINT)
defer can()
defer func() {
if err := recover(); err != nil {
log.Println("panic:", err)
panic(err)
}
}()
if err := src.Main(ctx); err != nil && ctx.Err() == nil {
panic(err)
}

View File

@@ -1,6 +1,12 @@
package button
import "fmt"
type Button struct {
Char byte
Down bool
}
func (button Button) String() string {
return fmt.Sprintf("%c:%v", button.Char, button.Down)
}

View File

@@ -9,11 +9,16 @@ import (
type (
config struct {
lock *sync.Mutex
Feedback configFeedback
Users map[string]configUser
Players []configPlayer
Quiet bool
lock *sync.Mutex
Feedback configFeedback
Users map[string]configUser
Players []configPlayer
Quiet bool
Broadcast configBroadcast
}
configBroadcast struct {
Message string
}
configFeedback struct {

View File

@@ -77,11 +77,28 @@ func (v01 *V01) serveHTTP(w http.ResponseWriter, r *http.Request) {
}
func (v01 *V01) getUserFeedback(w http.ResponseWriter, r *http.Request) {
user, ok := v01.cfg.Users[r.URL.Query().Get("user")]
if !ok {
user = v01.cfg.Users["broadcast"]
user := v01.cfg.Users[r.URL.Query().Get("user")]
msg := user.State.Message
if msg == "" {
msg = v01.cfg.Broadcast.Message
}
alias := user.State.GM.Alias
if alias == "" {
alias = user.State.GM.LastAlias
}
if alias != "" {
msg = fmt.Sprintf("%s (Your secret word is '%s'. Make **someone else** say it!)", msg, alias)
}
w.Write([]byte(msg + "\n\n"))
v01.serveGMStatus(w)
if v01.cfg.Quiet {
w.Write([]byte("\n\n"))
v01.serveGMVoteRead(w)
}
w.Write([]byte(user.State.Message))
}
func (v01 *V01) servePutBroadcast(w http.ResponseWriter, r *http.Request) {
@@ -90,9 +107,7 @@ func (v01 *V01) servePutBroadcast(w http.ResponseWriter, r *http.Request) {
}
func (v01 *V01) servePutBroadcastValue(v string) {
u := v01.cfg.Users["broadcast"]
u.State.Message = v
v01.cfg.Users["broadcast"] = u
v01.cfg.Broadcast.Message = v
}
func (v01 *V01) serveConfig(w http.ResponseWriter, r *http.Request) {
@@ -161,7 +176,7 @@ func (v01 *V01) serveGlobalQueryRefresh(r *http.Request) {
func (v01 *V01) serveGM(w http.ResponseWriter, r *http.Request) {
switch r.URL.Path {
case "/gm/rpc/status":
v01.serveGMStatus(w, r)
v01.serveGMStatus(w)
case "/gm/rpc/broadcastSomeoneSaidAlias":
v01.serveGMSomeoneSaidAlias(w, r)
case "/gm/rpc/fillNonPlayerAliases":
@@ -183,25 +198,29 @@ func (v01 *V01) serveGM(w http.ResponseWriter, r *http.Request) {
}
}
func (v01 *V01) serveGMStatus(w http.ResponseWriter, r *http.Request) {
users := map[string]struct {
Lag time.Duration `yaml:"lag,omitempty"`
Player int `yaml:"player,omitempty"`
IdleFor time.Duration `yaml:"idle_for,omitempty"`
}{}
func (v01 *V01) serveGMStatus(w io.Writer) {
users := map[string]string{}
for k, v := range v01.cfg.Users {
v2 := users[k]
v2.Lag = time.Duration(v.Meta.LastLag) * time.Millisecond
v2.Player = v.State.Player
if v.Meta.LastTSMS > 0 {
v2.IdleFor = time.Since(time.Unix(0, v.Meta.LastTSMS*int64(time.Millisecond)))
result := ""
if v.State.Player > 0 {
result += fmt.Sprintf("Player %v ", v.State.Player)
}
users[k] = v2
if ms := time.Duration(v.Meta.LastLag) * time.Millisecond; v.Meta.LastLag > 0 && ms < time.Minute {
result += fmt.Sprintf("%s ", ms.String())
}
if result == "" {
result = "..."
}
users[k] = result
}
yaml.NewEncoder(w).Encode(map[string]interface{}{
b, _ := yaml.Marshal(map[string]interface{}{
"Players": len(v01.cfg.Players),
"Users": users,
})
w.Write(b)
}
func (v01 *V01) serveGMSomeoneSaidAlias(w http.ResponseWriter, r *http.Request) {
@@ -282,28 +301,36 @@ func (v01 *V01) serveGMElect(w http.ResponseWriter, r *http.Request) {
func (v01 *V01) serveGMVote(w http.ResponseWriter, r *http.Request) {
switch r.URL.Query().Get("payload") {
case "":
counts := map[string]string{}
for k, v := range v01.cfg.Users {
if v.State.GM.Vote != "" {
counts[k] = "voted"
} else {
counts[k] = "voting"
}
}
yaml.NewEncoder(w).Encode(counts)
v01.serveGMVoteRead(w)
default:
voter := r.URL.Query().Get("user")
candidate := r.URL.Query().Get("payload")
v, ok := v01.cfg.Users[voter]
if _, ok2 := v01.cfg.Users[candidate]; !ok || !ok2 {
http.Error(w, "bad voter/candidate", http.StatusBadRequest)
return
}
v.State.GM.Vote = candidate
v01.cfg.Users[voter] = v
v01.serveGMVoteWrite(w, r)
}
}
func (v01 *V01) serveGMVoteRead(w io.Writer) {
counts := map[string]string{}
for k, v := range v01.cfg.Users {
if v.State.GM.Vote != "" {
counts[k] = "voted"
} else {
counts[k] = "voting"
}
}
yaml.NewEncoder(w).Encode(counts)
}
func (v01 *V01) serveGMVoteWrite(w http.ResponseWriter, r *http.Request) {
voter := r.URL.Query().Get("user")
candidate := r.URL.Query().Get("payload")
v, ok := v01.cfg.Users[voter]
if _, ok2 := v01.cfg.Users[candidate]; !ok || !ok2 {
http.Error(w, "bad voter/candidate", http.StatusBadRequest)
return
}
v.State.GM.Vote = candidate
v01.cfg.Users[voter] = v
}
func (v01 *V01) serveGMShuffle(r *http.Request) {
poolSize := len(v01.cfg.Users)
if altSize := len(v01.cfg.Players); altSize > poolSize {

View File

@@ -183,10 +183,8 @@ func TestServeGM(t *testing.T) {
},
Message: "if someone else says 'driver', then you get to play",
}},
"broadcast": configUser{State: configUserState{
Message: ":)",
}},
}
v01.cfg.Broadcast.Message = ":)"
do(v01, "/gm/rpc/broadcastSomeoneSaidAlias", "")
if !v01.cfg.Quiet {
t.Error(v01.cfg.Quiet)
@@ -196,7 +194,7 @@ func TestServeGM(t *testing.T) {
} else if v.State.GM.LastAlias != "driver" {
t.Error(v.State.GM.LastAlias)
}
if bc := v01.cfg.Users["broadcast"]; bc.State.Message == ":)" {
if bc := v01.cfg.Broadcast.Message; bc == ":)" {
t.Error(bc)
}
})
@@ -342,8 +340,8 @@ func TestServeGM(t *testing.T) {
} else if v01.cfg.Users["zach"].State.Player != 1 {
t.Error(v01.cfg.Users["zach"].State.Player)
}
if v01.cfg.Users["broadcast"].State.Message != `bel is now player 0 and zach is now player 1` {
t.Error(v01.cfg.Users["broadcast"].State.Message)
if v01.cfg.Broadcast.Message != `bel is now player 0 and zach is now player 1` {
t.Error(v01.cfg.Broadcast)
}
})
@@ -367,8 +365,8 @@ func TestServeGM(t *testing.T) {
} else if result["zach"] != 1 {
t.Error(result)
}
if !strings.HasSuffix(v01.cfg.Users["broadcast"].State.Message, `is now player 1`) || strings.Contains(v01.cfg.Users["broadcast"].State.Message, ",") {
t.Error(v01.cfg.Users["broadcast"].State.Message)
if !strings.HasSuffix(v01.cfg.Broadcast.Message, `is now player 1`) || strings.Contains(v01.cfg.Broadcast.Message, ",") {
t.Error(v01.cfg.Broadcast.Message)
}
assignments := map[int]int{}
for _, v := range v01.cfg.Users {
@@ -376,7 +374,7 @@ func TestServeGM(t *testing.T) {
}
if len(assignments) != 2 {
t.Error(assignments)
} else if assignments[0] != 3 {
} else if assignments[0] != 2 {
t.Error(assignments[0])
} else if assignments[1] != 1 {
t.Error(assignments[1])
@@ -402,8 +400,8 @@ func TestServeGM(t *testing.T) {
} else if result["zach"] != 1 {
t.Error(result)
}
if !strings.HasSuffix(v01.cfg.Users["broadcast"].State.Message, `is now player 1`) || strings.Contains(v01.cfg.Users["broadcast"].State.Message, ",") {
t.Error(v01.cfg.Users["broadcast"].State.Message)
if bc := v01.cfg.Broadcast.Message; !strings.HasSuffix(bc, `is now player 1`) || strings.Contains(bc, ",") {
t.Error(bc)
}
assignments := map[int]int{}
for _, v := range v01.cfg.Users {
@@ -411,7 +409,7 @@ func TestServeGM(t *testing.T) {
}
if len(assignments) != 2 {
t.Error(assignments)
} else if assignments[0] != 2 {
} else if assignments[0] != 1 {
t.Error(assignments[0])
} else if assignments[1] != 1 {
t.Error(assignments[1])
@@ -433,7 +431,7 @@ func TestServeGM(t *testing.T) {
if v01.cfg.Quiet {
t.Error(v01.cfg.Quiet)
}
if len(v01.cfg.Users) != 3 {
if len(v01.cfg.Users) != 2 {
t.Error(v01.cfg.Users)
} else if len(v01.cfg.Players) != 2 {
t.Error(v01.cfg.Users)
@@ -482,7 +480,7 @@ func TestServeGM(t *testing.T) {
t.Error(v01.cfg.Quiet)
}
if len(v01.cfg.Users) != c.users+1 {
if len(v01.cfg.Users) != c.users {
t.Error(v01.cfg.Users)
} else if len(v01.cfg.Players) != c.players {
t.Error(v01.cfg.Users)

View File

@@ -3,23 +3,18 @@ feedback:
ttsurl: http://localhost:15002
users:
bel:
meta:
lasttsms: 1681062770999
lastlag: 12
state:
player: 0
message: "hi"
alias: driver
meta:
tsms: 1
lastlag: 2
message: hi
gm:
alias: ""
lastalias: ""
vote: ""
players:
- buttons:
up: "w"
down: "s"
left: "a"
right: "d"
l: "q"
r: "e"
a: "1"
b: "2"
x: "3"
y: "4"
- transformation: {}
quiet: false
broadcast:
message: hi

View File

@@ -91,9 +91,8 @@ func TestV01Feedback(t *testing.T) {
state:
player: 2
message: to bel
broadcast:
state:
message: to everyone
broadcast:
message: to everyone
players:
- transformation:
w: t
@@ -124,8 +123,8 @@ func TestV01Feedback(t *testing.T) {
}
defer resp.Body.Close()
b, _ := io.ReadAll(resp.Body)
if string(b) != "to bel" {
t.Error(b)
if !strings.HasPrefix(string(b), "to bel") {
t.Error(string(b))
}
})
@@ -136,8 +135,8 @@ func TestV01Feedback(t *testing.T) {
}
defer resp.Body.Close()
b, _ := io.ReadAll(resp.Body)
if string(b) != "to everyone" {
t.Error(b)
if !strings.HasPrefix(string(b), "to everyone") {
t.Error(string(b))
}
})
@@ -156,7 +155,7 @@ func TestV01Feedback(t *testing.T) {
}
defer resp.Body.Close()
b, _ := io.ReadAll(resp.Body)
if string(b) != want {
if !strings.HasPrefix(string(b), want) {
t.Error(string(b))
}
})

View File

@@ -0,0 +1,155 @@
<!DOCTYPE html>
<html>
<header>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/water.css@2/out/dark.css">
<script>
function formsay(message) {
console.log(`say '${message}'`)
http("GET", `/proxy?user=${document.getElementById("user").value}&say=${message}`, noopcallback, null)
}
function formsend(message) {
console.log(`send '${message}'`)
http("GET", `/proxy/gm/rpc/vote?user=${document.getElementById("user").value}&payload=${message}`, noopcallback, null)
}
function http(method, remote, callback, body) {
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == XMLHttpRequest.DONE) {
callback(xmlhttp.responseText, xmlhttp.status)
}
};
xmlhttp.open(method, remote, true);
if (typeof body == "undefined") {
body = null
}
xmlhttp.send(body);
}
function noopcallback(responseBody, responseStatus) {
}
setInterval(() => {
http("GET", `/proxy?user=${document.getElementById("user").value}`, (b, s) => {
if (s != 200)
return
document.getElementById("ntfy").innerHTML = `<pre>${b}</pre>`
}, null)
}, 1500)
</script>
</header>
<body>
<div>
<form>
<h3>WHO AM I</h3>
<select id="user">
<option>bel</option>
<option>zach</option>
<option>chase</option>
<option>mason</option>
<option>nat</option>
<option>roxy</option>
<option>bill</option>
</select>
</form>
<div>
<form action="" onsubmit="formsay(this.children.say.value); return false;" style="display: inline-block;">
<h3>SAY</h3>
<input type="text" name="say">
<input type="submit" value="say">
</form>
<form action="" onsubmit="formsend(this.children.send.value); return false;" style="display: inline-block;">
<h3>SEND</h3>
<select name="send">
<option>bel</option>
<option>zach</option>
<option>chase</option>
<option>mason</option>
<option>nat</option>
<option>roxy</option>
<option>bill</option>
</select>
<input type="submit" value="send">
</form>
</div>
<details>
<summary>CONTROLS</summary>
<form id="controls">
<div style="display: flex; flex-wrap: wrap;">
<div>
<input type="text" maxLength=1 value="w" name="w" placeholder="up" onchange="recontrol()">
<input type="text" maxLength=1 value="s" name="s" placeholder="down" onchange="recontrol()">
<input type="text" maxLength=1 value="a" name="a" placeholder="left" onchange="recontrol()">
<input type="text" maxLength=1 value="d" name="d" placeholder="right" onchange="recontrol()">
</div>
<div>
<input type="text" maxLength=1 value="5" name="5" placeholder="start" onchange="recontrol()">
<input type="text" maxLength=1 value="q" name="q" placeholder="l" onchange="recontrol()">
<input type="text" maxLength=1 value="e" name="e" placeholder="r" onchange="recontrol()">
</div>
<div>
<input type="text" maxLength=1 value="1" name="1" placeholder="a" onchange="recontrol()">
<input type="text" maxLength=1 value="2" name="2" placeholder="b" onchange="recontrol()">
<input type="text" maxLength=1 value="3" name="3" placeholder="x" onchange="recontrol()">
<input type="text" maxLength=1 value="4" name="4" placeholder="y" onchange="recontrol()">
</div>
</div>
</form>
</details>
</div>
<div id="ntfy"></div>
<div id="ws"></div>
</body>
<footer>
<script>
var socket = new WebSocket("ws://"+window.location.host+"/api/ws")
function nosend(data) {
}
function dosend(data) {
console.log(JSON.stringify(data))
socket.send(JSON.stringify(data))
}
send = nosend
socket.addEventListener("open", (_) => {
console.log("ws open")
send = dosend
})
socket.addEventListener("message", (event) => console.log("ws recv:", event.data))
socket.addEventListener("close", (event) => console.log("ws closed"))
keys = {}
document.addEventListener('keydown', (event) => {
var name = controls[event.key]
if (!name)
return
if (keys[name])
return
keys[name] = true
sendKeys(name, "")
})
document.addEventListener('keyup', (event) => {
var name = controls[event.key]
if (!name)
return
keys[name] = false
sendKeys("", name)
})
function sendKeys(y, n) {
send({
T: new Date().getTime(),
U: document.getElementById("user").value,
Y: y,
N: n,
})
}
var controls = {}
function recontrol() {
for (var k in controls)
controls[k] = false
for (var e of document.getElementById("controls").getElementsByTagName("input"))
controls[e.value] = e.name
}
recontrol()
</script>
</footer>
</html>

View File

@@ -9,6 +9,8 @@ import (
var (
FlagRawKeyboard = os.Getenv("RAW_KEYBOARD") == "true"
FlagRawUDP = os.Getenv("RAW_UDP")
FlagRawWS = os.Getenv("RAW_WS")
FlagDebug = os.Getenv("DEBUG") != ""
FlagRawRandomWeightFile = os.Getenv("RAW_RANDOM_WEIGHT_FILE")
)
@@ -21,6 +23,9 @@ func New(ctx context.Context) Raw {
if FlagRawKeyboard {
return NewKeyboard()
}
if port, _ := strconv.Atoi(FlagRawWS); port != 0 {
return NewWS(ctx, port)
}
if port, _ := strconv.Atoi(FlagRawUDP); port != 0 {
return NewUDP(ctx, port)
}

View File

@@ -6,4 +6,5 @@ func TestRaw(t *testing.T) {
var _ Raw = &Random{}
var _ Raw = UDP{}
var _ Raw = Keyboard{}
var _ Raw = WS{}
}

View File

@@ -4,14 +4,9 @@ import (
"context"
"log"
"net"
"os"
"strconv"
)
var (
FlagDebug = os.Getenv("DEBUG") == "true"
)
type UDP struct {
conn net.PacketConn
c chan []byte

145
src/device/input/raw/ws.go Normal file
View File

@@ -0,0 +1,145 @@
package raw
import (
"context"
_ "embed"
"fmt"
"log"
"net/http"
"net/http/httputil"
"net/url"
"os"
"strings"
"github.com/gorilla/websocket"
)
var (
FlagWSProxy = os.Getenv("RAW_WS_PROXY_URL")
FlagWSDebug = os.Getenv("RAW_WS_DEBUG") != ""
)
type WS struct {
ctx context.Context
can context.CancelFunc
ch chan []byte
}
func NewWS(ctx context.Context, port int) WS {
ctx, can := context.WithCancel(ctx)
ws := WS{ctx: ctx, can: can, ch: make(chan []byte, 256)}
go ws.listen(port)
return ws
}
func (ws WS) Read() []byte {
select {
case v := <-ws.ch:
return v
case <-ws.ctx.Done():
return nil
}
}
func (ws WS) Close() {
ws.can()
}
func (ws WS) listen(port int) {
server := &http.Server{
Addr: fmt.Sprintf(":%d", port),
Handler: ws,
}
go func() {
if err := server.ListenAndServe(); err != nil && ws.ctx.Err() == nil {
panic(err)
}
}()
log.Println("WS on", port)
<-ws.ctx.Done()
server.Close()
}
var upgrader = websocket.Upgrader{
ReadBufferSize: 1024,
WriteBufferSize: 1024,
}
func (ws WS) ServeHTTP(w http.ResponseWriter, r *http.Request) {
r = r.WithContext(ws.ctx)
if err := ws.serveHTTP(w, r); err != nil {
log.Println(err)
http.Error(w, err.Error(), http.StatusInternalServerError)
}
}
func (ws WS) serveHTTP(w http.ResponseWriter, r *http.Request) error {
switch r.URL.Path {
case "/":
return ws.serveIndex(w, r)
case "/api/ws":
return ws.serveWS(w, r)
}
if strings.HasPrefix(r.URL.Path, "/proxy") {
return ws.serveProxy(w, r)
}
http.NotFound(w, r)
return nil
}
func (ws WS) serveProxy(w http.ResponseWriter, r *http.Request) error {
u, err := url.Parse(FlagWSProxy)
if err != nil {
return err
}
r.URL.Path = strings.TrimPrefix(r.URL.Path, "/proxy")
if r.URL.Path == "" {
r.URL.Path = "/"
}
proxy := httputil.NewSingleHostReverseProxy(u)
proxy.ServeHTTP(w, r)
return nil
}
//go:embed public/root.html
var rootHTML string
func (ws WS) serveIndex(w http.ResponseWriter, r *http.Request) error {
v := rootHTML
if FlagWSDebug {
b, _ := os.ReadFile("src/device/input/raw/public/root.html")
v = string(b)
}
w.Write([]byte(v))
return nil
}
func (ws WS) serveWS(w http.ResponseWriter, r *http.Request) error {
if err := ws._serveWS(w, r); err != nil {
log.Println("_serveWS:", err)
}
return nil
}
func (ws WS) _serveWS(w http.ResponseWriter, r *http.Request) error {
conn, err := upgrader.Upgrade(w, r, nil)
if err != nil {
return err
}
defer conn.Close()
for ws.ctx.Err() == nil {
msgType, p, err := conn.ReadMessage()
if err != nil {
if websocket.IsCloseError(err) || websocket.IsUnexpectedCloseError(err) {
return nil
}
return err
}
if msgType == websocket.TextMessage {
log.Println(string(p))
ws.ch <- p
}
}
return nil
}

View File

@@ -17,9 +17,9 @@ func Main(ctx context.Context) error {
defer reader.Close()
interval := time.Millisecond * 50
if intervalS := os.Getenv("MAIN_INTERVAL_DURATION"); intervalS != "" {
if intervalS := os.Getenv("MAIN_INTERVAL_DURATION"); intervalS == "" {
} else if v, err := time.ParseDuration(intervalS); err != nil {
panic(err)
return err
} else {
interval = v
}
@@ -50,6 +50,9 @@ func Main(ctx context.Context) error {
keys = append(keys, k)
}
}
if os.Getenv("DEBUG") == "true" {
log.Printf("src.Main.writer.Press(%+v) (from %+v)", keys, delta)
}
writer.Press(keys...)
}

104
todo.yaml
View File

@@ -1,104 +0,0 @@
todo:
- -venue needs to update for new env variables for GUI
- -venue needs to udpate hits hotword path for new Users.[].State.GM.Alias
- clients can vote
- single docker image to run all
- https via home.blapointe and rproxy
- trigger dolphin pause via query param mapping to a button that is a pause hotkey
- todo: rotation triggers
subtasks:
- ui for election start, election votes, election end stuff
- todo: stdin
subtasks:
- minigame end
- todo: voice recognition of hotwords to vote who dun it
subtasks:
- random word from cur wikipedia page
- each person has their own hotword
- only spectators have hotwords and must get a player to speak it
- tribunal to vote who said it
scheduled: []
done:
- todo: sticky keyboard input mode for enable/disable explicitly
ts: Thu Mar 23 20:55:52 MDT 2023
- todo: case-sensitive
ts: Fri Mar 24 13:39:26 MDT 2023
- todo: rusty configs have "name" for each client so "if name == server_broadcasted_name
{ debug_print_in_gui(server_broadcasted_message) }
ts: Fri Mar 24 16:40:09 MDT 2023
- todo: change from 'a','b','c' from rust to just 10,11,12 so playerName is known
implicitly but then gotta translate back to char for keyboard things somewhere;
space delimited?
ts: Fri Mar 24 17:00:55 MDT 2023
- todo: '"Button" to interface or strings'
ts: Fri Mar 24 17:01:01 MDT 2023
- todo: input.UDP as a raw provider
ts: Fri Mar 24 19:58:59 MDT 2023
- todo: input.MayhemParty as a logical wrapper
ts: Fri Mar 24 19:58:59 MDT 2023
- todo: change from 'a','b','c' from rust to just 11,21,31,41 so playerName is known
implicitly from %10 but then gotta translate back to char for keyboard things
somewhere; space delimited?
ts: Fri Mar 24 19:58:59 MDT 2023
- todo: input."Button" to interface or strings
ts: Fri Mar 24 21:16:39 MDT 2023
- todo: input.MayhemParty as a logical wrapper from %10 but then gotta translate back
to char for keyboard things somewhere; space delimited?
ts: Fri Mar 24 21:16:39 MDT 2023
- todo: change from 'a','b','c' from rust to just 11,21,31,41 so playerName is known
implicitly
ts: Sat Mar 25 00:06:21 MDT 2023
- todo: lag via UDP formatted inputs as space-delimited TS PID buttonIdx buttonIdx
buttonIdx
ts: Sat Mar 25 00:13:19 MDT 2023
- todo: map keys triggered by user to player idx and their keys
ts: Sat Mar 25 00:44:19 MDT 2023
- todo: use button.V01Cfg; map keys triggered by user to player idx and their keys
ts: Sat Mar 25 09:12:43 MDT 2023
- todo: v01cfg includes messages to send per client and exposes tcp server for it
ts: Sat Mar 25 10:09:06 MDT 2023
- todo: v01cfg includes messages to send per client and exposes http server for it
ts: Sat Mar 25 11:28:29 MDT 2023
- todo: send clients messages to display
ts: Sat Mar 25 11:28:29 MDT 2023
- todo: input.MayhemParty as a logical wrapper from mod10 but then gotta translate
back to char for keyboard things somewhere; space delimited?
ts: Sat Mar 25 11:28:40 MDT 2023
- todo: rusty configs have "name" for each client
details: |
'if name == server_broadcasted_name { debug_print_in_gui(server_broadcasted_message) }'
ts: Sat Mar 25 11:28:40 MDT 2023
- todo: rotation triggers
subtasks:
- minigame end
- random word from cur wikipedia page
- each person has their own hotword
- only spectators have hotwords and must get a player to speak it
- tribunal to vote who said it
ts: Sat Mar 25 11:29:52 MDT 2023
- todo: we have 7 players oooooof
ts: Sat Mar 25 11:29:52 MDT 2023
- todo: endpoint for v01 to start read-only mode so when hotword spoken, players are
dcd without losing players
ts: Sat Mar 25 23:16:47 MDT 2023
- todo: tts for when someone said the word via larynx docker + http.get + https://pkg.go.dev/github.com/faiface/beep@v1.1.0/wav
ts: Sun Mar 26 09:57:02 MDT 2023
- todo: 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
ts: Sun Mar 26 14:28:46 MDT 2023
- todo: game master to coordinate config change
ts: Mon Mar 27 11:01:10 MDT 2023
- todo: rotation triggers
subtasks:
- todo: stdin
subtasks:
- minigame end
- todo: voice recognition of hotwords to vote who dun it
subtasks:
- random word from cur wikipedia page
- each person has their own hotword
- only spectators have hotwords and must get a player to speak it
- tribunal to vote who said it
ts: Mon Mar 27 11:04:56 MDT 2023
- todo: clients can send STT via box
ts: Mon Mar 27 17:55:41 MDT 2023