Wire websocket forwarder with players updater.

This commit is contained in:
Sascha L. Teichmann 2015-03-09 13:16:31 +01:00
parent ece8924355
commit da51389935
2 changed files with 11 additions and 9 deletions

View File

@ -65,20 +65,21 @@ func main() {
router.Path("/map/{z:[0-9]+}/{x:[0-9]+}/{y:[0-9]+}.png").Handler(subBaseLine)
var btu baseTilesUpdates
if playersFIFO != "" {
plys := newPlayers(playersFIFO)
go plys.run()
router.Path("/players").Methods("GET").Handler(plys)
}
var wsf *websocketForwarder
if websockets {
wsf := newWebsocketForwarder()
wsf = newWebsocketForwarder()
go wsf.run()
router.Path("/ws").Methods("GET").Handler(wsf)
btu = wsf
}
if playersFIFO != "" {
plys := newPlayers(playersFIFO, wsf)
go plys.run()
router.Path("/players").Methods("GET").Handler(plys)
}
if redisHost != "" {
var colors *common.Colors
var err error

View File

@ -4,10 +4,11 @@ import "net/http"
type players struct {
fifo string
wsf *websocketForwarder
}
func newPlayers(fifo string) *players {
return &players{fifo: fifo}
func newPlayers(fifo string, wsf *websocketForwarder) *players {
return &players{fifo: fifo, wsf: wsf}
}
func (ps *players) run() {