diff --git a/cmd/mtwebmapper/main.go b/cmd/mtwebmapper/main.go index eef25af..86370f6 100644 --- a/cmd/mtwebmapper/main.go +++ b/cmd/mtwebmapper/main.go @@ -29,6 +29,7 @@ func main() { transparent bool updateHosts string websockets bool + playersFIFO string ) flag.IntVar(&webPort, "web-port", 8808, "port of the web server") flag.IntVar(&webPort, "p", 8808, "port of the web server (shorthand)") @@ -53,6 +54,8 @@ func main() { flag.BoolVar(&transparent, "t", false, "Render transparent blocks (shorthand).") flag.BoolVar(&websockets, "websockets", false, "Forward tile changes to clients via websockets.") flag.BoolVar(&websockets, "ws", false, "Forward tile changes to clients via websockets (shorthand).") + flag.StringVar(&playersFIFO, "players", "", "Path to FIFO file to read active players from.") + flag.StringVar(&playersFIFO, "ps", "", "Path to FIFO file to read active players from (shorthand).") flag.Parse() @@ -63,6 +66,12 @@ func main() { var btu baseTilesUpdates + if playersFIFO != "" { + plys := newPlayers(playersFIFO) + go plys.run() + router.Path("/players").Methods("GET").Handler(plys) + } + if websockets { wsf := newWebsocketForwarder() go wsf.run() diff --git a/cmd/mtwebmapper/players.go b/cmd/mtwebmapper/players.go new file mode 100644 index 0000000..726453f --- /dev/null +++ b/cmd/mtwebmapper/players.go @@ -0,0 +1,21 @@ +package main + +import "net/http" + +type players struct { + fifo string +} + +func newPlayers(fifo string) *players { + return &players{fifo: fifo} +} + +func (ps *players) run() { + for { + // TODO: Implement me! + } +} + +func (ps *players) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + // TODO: Implement me! +}