Browse Source

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.
master
Stephen McQuay 6 years ago
parent
commit
ff3f9a5137
1 changed files with 8 additions and 1 deletions
  1. +8
    -1
      protocol.go

+ 8
- 1
protocol.go 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"))

Loading…
Cancel
Save