Add stub for players controller.

This commit is contained in:
Sascha L. Teichmann 2015-03-09 13:09:13 +01:00
parent 89413f753c
commit ece8924355
2 changed files with 30 additions and 0 deletions

View File

@ -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()

View File

@ -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!
}