pared down logging in favor of unittests

This commit is contained in:
sm
2013-08-26 23:02:41 -07:00
parent 63f6d1a2e0
commit 1b29096479
5 changed files with 0 additions and 18 deletions
-8
View File
@@ -84,22 +84,17 @@ func NewFailure(reason string) *Failure {
func Negociate(ws *websocket.Conn, id string, width, height float64) (*Config, error) {
var err error
log.Printf("sending robot id: %s", id)
err = websocket.JSON.Send(ws, NewIdRequest(id))
if err != nil {
log.Printf("%s: problem sending initial identification", id)
return nil, errors.New("generic servr error")
}
var clientid ClientID
err = websocket.JSON.Receive(ws, &clientid)
if err != nil {
log.Printf("%s: problem parsing clientID", id)
return nil, errors.New("could not parse id")
}
if v, msg := clientid.Valid(); !v {
log.Printf("%s: invalid clientid: %+v", id, clientid)
websocket.JSON.Send(
ws,
NewFailure(msg),
@@ -110,7 +105,6 @@ func Negociate(ws *websocket.Conn, id string, width, height float64) (*Config, e
gameParam := NewGameParam(width, height)
err = websocket.JSON.Send(ws, gameParam)
if err != nil {
log.Println("%s: problem sending game info: %+v", id, gameParam)
websocket.JSON.Send(ws, NewFailure("generic server error"))
return nil, err
}
@@ -128,10 +122,8 @@ func Negociate(ws *websocket.Conn, id string, width, height float64) (*Config, e
break
} else {
_ = websocket.JSON.Send(ws, NewHandshake(id, false))
log.Printf("%s invalid config", id)
}
}
log.Printf("%s eventually sent valid config: %+v", id, conf)
return &conf, nil
case "spectator":
return nil, nil