From ff3f9a51376b950f9ed588854b5c10e554bbfd53 Mon Sep 17 00:00:00 2001 From: Stephen McQuay Date: Thu, 23 Jan 2014 23:00:43 -0800 Subject: [PATCH] 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. --- protocol.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/protocol.go b/protocol.go index 9abaad3..2670bb1 100644 --- a/protocol.go +++ b/protocol.go @@ -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"))