6 Commits

Author SHA1 Message Date
bel
7df4d09553 update rusty-pipes for feedback 2023-03-25 14:51:19 -06:00
bel
1ad60189f4 todo 2023-03-25 11:29:54 -06:00
bel
766c77b00a todo 2023-03-25 11:28:41 -06:00
bel
bcdf545188 todo 2023-03-25 11:28:30 -06:00
bel
3264d9ad55 can send messages back to specific and ALL viewers 2023-03-25 11:27:49 -06:00
bel
3f35f7f936 manual test w rusty-pipe v0.1.3 ok 2023-03-25 11:01:38 -06:00
13 changed files with 177 additions and 26 deletions

View File

@@ -4,3 +4,4 @@ export BUTTON_V01=true
export WRAP_REFRESH_ON_SIGUSR1=true export WRAP_REFRESH_ON_SIGUSR1=true
export MAIN_INTERVAL_DURATION=5ms export MAIN_INTERVAL_DURATION=5ms
export OUTPUT_KEYBOARD=false export OUTPUT_KEYBOARD=false
export BUTTON_V01_CONFIG=./config.d/mayhem-party.d/v01.yaml

View File

@@ -1 +1 @@
players_offset_0.yaml players_offset_4.yaml

View File

@@ -0,0 +1,21 @@
feedback:
addr: :17071
users:
bel:
player: 2
message: its bel
broadcast:
message: 8
players:
- {}
- transformation:
w: t
a: f
s: g
d: h
q: r
e: y
1: 5
2: 6
3: 7
4: 8

View File

@@ -5,6 +5,8 @@ streams:
name: gui name: gui
gui: gui:
user: bel user: bel
feedback:
url: http://mayhem-party.home.blapointe.com:17071?user=bel
press: {prefix: "", suffix: ""} press: {prefix: "", suffix: ""}
release: {prefix: "", suffix: ""} release: {prefix: "", suffix: ""}
format: '{"T":{{ms}},"U":"{{user}}","Y":"{{pressed}}","N":"{{released}}"}' format: '{"T":{{ms}},"U":"{{user}}","Y":"{{pressed}}","N":"{{released}}"}'
@@ -20,7 +22,7 @@ streams:
x: '3' x: '3'
y: '4' y: '4'
output: output:
debug: true debug: false
engine: engine:
name: udp name: udp
udp: udp:

View File

@@ -5,6 +5,8 @@ streams:
name: gui name: gui
gui: gui:
user: zach user: zach
feedback:
url: http://mayhem-party.home.blapointe.com:17071?user=zach
press: {prefix: "", suffix: ""} press: {prefix: "", suffix: ""}
release: {prefix: "", suffix: ""} release: {prefix: "", suffix: ""}
format: '{"T":{{ms}},"U":"{{user}}","Y":"{{pressed}}","N":"{{released}}"}' format: '{"T":{{ms}},"U":"{{user}}","Y":"{{pressed}}","N":"{{released}}"}'
@@ -20,7 +22,7 @@ streams:
x: '3' x: '3'
y: '4' y: '4'
output: output:
debug: true debug: false
engine: engine:
name: udp name: udp
udp: udp:

View File

@@ -4,7 +4,9 @@ streams:
engine: engine:
name: gui name: gui
gui: gui:
user: mason user: chase
feedback:
url: http://mayhem-party.home.blapointe.com:17071?user=chase
press: {prefix: "", suffix: ""} press: {prefix: "", suffix: ""}
release: {prefix: "", suffix: ""} release: {prefix: "", suffix: ""}
format: '{"T":{{ms}},"U":"{{user}}","Y":"{{pressed}}","N":"{{released}}"}' format: '{"T":{{ms}},"U":"{{user}}","Y":"{{pressed}}","N":"{{released}}"}'
@@ -20,7 +22,7 @@ streams:
x: '3' x: '3'
y: '4' y: '4'
output: output:
debug: true debug: false
engine: engine:
name: udp name: udp
udp: udp:

View File

@@ -4,7 +4,9 @@ streams:
engine: engine:
name: gui name: gui
gui: gui:
user: nat user: mason
feedback:
url: http://mayhem-party.home.blapointe.com:17071?user=mason
press: {prefix: "", suffix: ""} press: {prefix: "", suffix: ""}
release: {prefix: "", suffix: ""} release: {prefix: "", suffix: ""}
format: '{"T":{{ms}},"U":"{{user}}","Y":"{{pressed}}","N":"{{released}}"}' format: '{"T":{{ms}},"U":"{{user}}","Y":"{{pressed}}","N":"{{released}}"}'
@@ -20,7 +22,7 @@ streams:
x: '3' x: '3'
y: '4' y: '4'
output: output:
debug: true debug: false
engine: engine:
name: udp name: udp
udp: udp:

View File

@@ -4,7 +4,9 @@ streams:
engine: engine:
name: gui name: gui
gui: gui:
user: roxy user: nat
feedback:
url: http://mayhem-party.home.blapointe.com:17071?user=nat
press: {prefix: "", suffix: ""} press: {prefix: "", suffix: ""}
release: {prefix: "", suffix: ""} release: {prefix: "", suffix: ""}
format: '{"T":{{ms}},"U":"{{user}}","Y":"{{pressed}}","N":"{{released}}"}' format: '{"T":{{ms}},"U":"{{user}}","Y":"{{pressed}}","N":"{{released}}"}'
@@ -20,7 +22,7 @@ streams:
x: '3' x: '3'
y: '4' y: '4'
output: output:
debug: true debug: false
engine: engine:
name: udp name: udp
udp: udp:

View File

@@ -4,7 +4,9 @@ streams:
engine: engine:
name: gui name: gui
gui: gui:
user: chase user: roxy
feedback:
url: http://mayhem-party.home.blapointe.com:17071?user=roxy
press: {prefix: "", suffix: ""} press: {prefix: "", suffix: ""}
release: {prefix: "", suffix: ""} release: {prefix: "", suffix: ""}
format: '{"T":{{ms}},"U":"{{user}}","Y":"{{pressed}}","N":"{{released}}"}' format: '{"T":{{ms}},"U":"{{user}}","Y":"{{pressed}}","N":"{{released}}"}'
@@ -20,7 +22,7 @@ streams:
x: '3' x: '3'
y: '4' y: '4'
output: output:
debug: true debug: false
engine: engine:
name: udp name: udp
udp: udp:

View File

@@ -5,6 +5,8 @@ streams:
name: gui name: gui
gui: gui:
user: bill user: bill
feedback:
url: http://mayhem-party.home.blapointe.com:17071?user=bill
press: {prefix: "", suffix: ""} press: {prefix: "", suffix: ""}
release: {prefix: "", suffix: ""} release: {prefix: "", suffix: ""}
format: '{"T":{{ms}},"U":"{{user}}","Y":"{{pressed}}","N":"{{released}}"}' format: '{"T":{{ms}},"U":"{{user}}","Y":"{{pressed}}","N":"{{released}}"}'
@@ -20,7 +22,7 @@ streams:
x: '3' x: '3'
y: '4' y: '4'
output: output:
debug: true debug: false
engine: engine:
name: udp name: udp
udp: udp:

View File

@@ -6,6 +6,7 @@ import (
"io/ioutil" "io/ioutil"
"log" "log"
"mayhem-party/src/device/input/raw" "mayhem-party/src/device/input/raw"
"net/http"
"os" "os"
"time" "time"
@@ -31,6 +32,9 @@ type (
N string N string
} }
v01Cfg struct { v01Cfg struct {
Feedback struct {
Addr string
}
Users map[string]struct { Users map[string]struct {
Player int Player int
Message string Message string
@@ -47,12 +51,41 @@ func NewV01(ctx context.Context, src raw.Raw) V01 {
b, _ := ioutil.ReadFile(FlagButtonV01Config) b, _ := ioutil.ReadFile(FlagButtonV01Config)
yaml.Unmarshal(b, &cfg) yaml.Unmarshal(b, &cfg)
ctx, can := context.WithCancel(ctx) ctx, can := context.WithCancel(ctx)
return V01{ result := V01{
ctx: ctx, ctx: ctx,
can: can, can: can,
src: src, src: src,
cfg: cfg, cfg: cfg,
} }
go result.listen()
return result
}
func (v01 V01) listen() {
if v01.cfg.Feedback.Addr == "" {
return
}
s := &http.Server{
Addr: v01.cfg.Feedback.Addr,
Handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
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))
}),
}
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) CloseWrap() raw.Raw { func (v01 V01) CloseWrap() raw.Raw {

View File

@@ -3,7 +3,9 @@ package button_test
import ( import (
"context" "context"
"fmt" "fmt"
"io"
"mayhem-party/src/device/input/button" "mayhem-party/src/device/input/button"
"net/http"
"os" "os"
"path" "path"
"testing" "testing"
@@ -14,6 +16,7 @@ func TestV01(t *testing.T) {
src := constSrc(fmt.Sprintf(`{"T":%v,"U":"bel","Y":"abc","N":"cde"}`, time.Now().UnixNano()/int64(time.Millisecond)-50)) src := constSrc(fmt.Sprintf(`{"T":%v,"U":"bel","Y":"abc","N":"cde"}`, time.Now().UnixNano()/int64(time.Millisecond)-50))
t.Logf("(%v) %s", len(src), src.Read()) t.Logf("(%v) %s", len(src), src.Read())
v01 := button.NewV01(context.Background(), src) v01 := button.NewV01(context.Background(), src)
defer v01.Close()
got := v01.Read() got := v01.Read()
want := []button.Button{ want := []button.Button{
{Down: true, Char: 'a'}, {Down: true, Char: 'a'},
@@ -50,6 +53,7 @@ func TestV01WithCfg(t *testing.T) {
t.Run("unknown user ignored", func(t *testing.T) { t.Run("unknown user ignored", func(t *testing.T) {
v01 := button.NewV01(context.Background(), constSrc(`{"U":"qt","Y":"w"}`)) v01 := button.NewV01(context.Background(), constSrc(`{"U":"qt","Y":"w"}`))
defer v01.Close()
got := v01.Read() got := v01.Read()
if len(got) != 0 { if len(got) != 0 {
t.Error(got) t.Error(got)
@@ -58,6 +62,7 @@ func TestV01WithCfg(t *testing.T) {
t.Run("player2", func(t *testing.T) { t.Run("player2", func(t *testing.T) {
v01 := button.NewV01(context.Background(), constSrc(`{"U":"bel","Y":"w","N":"w"}`)) v01 := button.NewV01(context.Background(), constSrc(`{"U":"bel","Y":"w","N":"w"}`))
defer v01.Close()
got := v01.Read() got := v01.Read()
if len(got) != 2 { if len(got) != 2 {
t.Error(got) t.Error(got)
@@ -70,3 +75,63 @@ func TestV01WithCfg(t *testing.T) {
} }
}) })
} }
func TestV01Feedback(t *testing.T) {
d := t.TempDir()
p := path.Join(d, "cfg.yaml")
os.WriteFile(p, []byte(`
feedback:
addr: :27071
users:
bel:
player: 2
message: to bel
broadcast:
message: to everyone
players:
- transformation:
w: t
- transformation:
w: i
`), os.ModePerm)
button.FlagButtonV01Config = p
ctx, can := context.WithCancel(context.Background())
defer can()
v01 := button.NewV01(ctx, constSrc(`{"U":"qt","Y":"w"}`))
defer v01.Close()
for {
time.Sleep(time.Millisecond * 100)
resp, err := http.Get("http://localhost:27071?user=bel")
if err != nil {
continue
}
resp.Body.Close()
break
}
t.Run("specific user", func(t *testing.T) {
resp, err := http.Get("http://localhost:27071?user=bel")
if err != nil {
t.Fatal(err)
}
defer resp.Body.Close()
b, _ := io.ReadAll(resp.Body)
if string(b) != "to bel" {
t.Error(b)
}
})
t.Run("broadcast", func(t *testing.T) {
resp, err := http.Get("http://localhost:27071")
if err != nil {
t.Fatal(err)
}
defer resp.Body.Close()
b, _ := io.ReadAll(resp.Body)
if string(b) != "to everyone" {
t.Error(b)
}
})
}

View File

@@ -1,19 +1,15 @@
todo: todo:
- v01cfg includes messages to send per client and exposes http server for it
- send clients messages to display
- input.MayhemParty as a logical wrapper from mod10 but then gotta translate back
to char for keyboard things somewhere; space delimited?
- todo: rusty configs have "name" for each client
details: |
'if name == server_broadcasted_name { debug_print_in_gui(server_broadcasted_message) }'
- todo: rotation triggers - todo: rotation triggers
subtasks: subtasks:
- minigame end - todo: stdin
- random word from cur wikipedia page subtasks:
- each person has their own hotword - minigame end
- only spectators have hotwords and must get a player to speak it - todo: voice recognition of hotwords to vote who dun it
- tribunal to vote who said it subtasks:
- we have 7 players oooooof - 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: [] scheduled: []
done: done:
- todo: sticky keyboard input mode for enable/disable explicitly - todo: sticky keyboard input mode for enable/disable explicitly
@@ -54,3 +50,24 @@ done:
ts: Sat Mar 25 09:12:43 MDT 2023 ts: Sat Mar 25 09:12:43 MDT 2023
- todo: v01cfg includes messages to send per client and exposes tcp server for it - todo: v01cfg includes messages to send per client and exposes tcp server for it
ts: Sat Mar 25 10:09:06 MDT 2023 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