changed the stats payload

As it turns out there are other citizens of this world, not just the botclient.
So I have properly labeled the payload with a type. This makes the web
front-end less breaky.
This commit is contained in:
Stephen McQuay 2014-01-23 23:00:43 -08:00
parent 7bb5ae59b3
commit ff3f9a5137
1 changed files with 8 additions and 1 deletions

View File

@ -247,7 +247,14 @@ func addPlayer(ws *websocket.Conn) {
p.Robots = append(p.Robots, &r)
}
err = websocket.JSON.Send(ws, &convertedStats)
statsPayload := struct {
Stats map[string]Stats `json:"stats"`
Type string `json:"type"`
}{
Stats: convertedStats,
Type: "stats",
}
err = websocket.JSON.Send(ws, &statsPayload)
if err != nil {
log.Printf("error sending convertedStats to client: %s", err)
websocket.JSON.Send(ws, NewFailure("protocol error: convertedStats"))