pared down logging in favor of unittests
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user