remote-i3wm-go/actions.go
Simon Vieille 6c524e2c41 init
2023-08-24 18:41:16 +02:00

24 lines
508 B
Go

package main
import (
"golang.org/x/net/websocket"
)
type Actions struct {
Functions map[string]func(ws *websocket.Conn, msg string) error
}
func (actions Actions) add(name string, callback func(ws *websocket.Conn, msg string) error) {
actions.Functions[name] = callback
}
func (actions Actions) has(name string) bool {
_, exists := actions.Functions[name]
return exists
}
func (actions Actions) exec(name string, ws *websocket.Conn, msg string) error {
return actions.Functions[name](ws, msg)
}