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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
encodings := []string{}
|
supportedEncs := []string{"bson", "json", "gob"}
|
||||||
err = websocket.JSON.Receive(r.ws, &encodings)
|
err = websocket.JSON.Send(r.ws, supportedEncs)
|
||||||
log.Printf("%+v", encodings)
|
|
||||||
desiredEncoding := "json"
|
|
||||||
for _, encoding := range encodings {
|
|
||||||
if "gob" == encoding {
|
|
||||||
desiredEncoding = encoding
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
err = websocket.JSON.Send(r.ws, desiredEncoding)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return errors.New(fmt.Sprintf("failure: %+v", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
err = websocket.JSON.Receive(r.ws, &r.game)
|
err = websocket.JSON.Receive(r.ws, &r.game)
|
||||||
@ -109,6 +100,7 @@ func (r *robot) negociate() (err error) {
|
|||||||
}
|
}
|
||||||
if *verbose {
|
if *verbose {
|
||||||
log.Printf("%s: game parameters: %+v", r.name, r.game)
|
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
|
// TODO: do something with r.game.Protocol
|
||||||
log.Printf("game params: %+v", r.game)
|
log.Printf("game params: %+v", r.game)
|
||||||
|
Loading…
Reference in New Issue
Block a user