Implemented Fraser's suggestions
This commit is contained in:
parent
21705cc16e
commit
eec52769dd
16
robot.go
16
robot.go
@ -88,19 +88,10 @@ func (r *robot) negociate() (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
encodings := []string{}
|
||||
err = websocket.JSON.Receive(r.ws, &encodings)
|
||||
log.Printf("%+v", encodings)
|
||||
desiredEncoding := "json"
|
||||
for _, encoding := range encodings {
|
||||
if "gob" == encoding {
|
||||
desiredEncoding = encoding
|
||||
break
|
||||
}
|
||||
}
|
||||
err = websocket.JSON.Send(r.ws, desiredEncoding)
|
||||
supportedEncs := []string{"bson", "json", "gob"}
|
||||
err = websocket.JSON.Send(r.ws, supportedEncs)
|
||||
if err != nil {
|
||||
return err
|
||||
return errors.New(fmt.Sprintf("failure: %+v", err))
|
||||
}
|
||||
|
||||
err = websocket.JSON.Receive(r.ws, &r.game)
|
||||
@ -109,6 +100,7 @@ func (r *robot) negociate() (err error) {
|
||||
}
|
||||
if *verbose {
|
||||
log.Printf("%s: game parameters: %+v", r.name, r.game)
|
||||
return errors.New(fmt.Sprintf("failure: %+v", err))
|
||||
}
|
||||
// TODO: do something with r.game.Protocol
|
||||
log.Printf("game params: %+v", r.game)
|
||||
|
Loading…
Reference in New Issue
Block a user