allow for overriding encodings

This commit is contained in:
Stephen McQuay 2014-03-11 07:30:05 -07:00
parent 839b5789e3
commit bb3d9e16e4
2 changed files with 4 additions and 0 deletions

View File

@ -29,6 +29,7 @@ var botname = flag.String("name", "gobot", "the name that other players will see
var botcount = flag.Int("bots", 1, "number of bots to spin up")
var verbose = flag.Bool("verbose", false, "run verbosly")
var forceJSON = flag.Bool("json", false, "force json encoding")
func main() {
log.SetFlags(log.Ldate | log.Ltime | log.Lshortfile)

View File

@ -99,6 +99,9 @@ func (r *robot) negociate() (err error) {
}
supportedEncs := []string{"bson", "json", "gob"}
if *forceJSON {
supportedEncs = []string{"json"}
}
err = websocket.JSON.Send(r.ws, supportedEncs)
if err != nil {
return errors.New(fmt.Sprintf("failure: %+v", err))