logging and infinite melee

This commit is contained in:
sm
2013-09-27 00:03:32 -07:00
parent 13c0cd047b
commit 472e2011b9
3 changed files with 9 additions and 7 deletions
+7
View File
@@ -4,6 +4,7 @@ import (
"bitbucket.org/hackerbots/bot"
"code.google.com/p/go.net/websocket"
"errors"
"log"
)
func Negociate(ws *websocket.Conn, id string, width, height float64) (*bot.Config, error) {
@@ -20,12 +21,14 @@ func Negociate(ws *websocket.Conn, id string, width, height float64) (*bot.Confi
return nil, errors.New("could not parse id")
}
if v, msg := clientid.Valid(); !v {
log.Printf("clientid is invalid: %+v", clientid)
websocket.JSON.Send(
ws,
bot.NewFailure(msg),
)
return nil, errors.New(msg)
}
log.Printf("clientid: %+v", clientid)
gameParam := bot.NewGameParam(width, height)
err = websocket.JSON.Send(ws, gameParam)
@@ -33,11 +36,15 @@ func Negociate(ws *websocket.Conn, id string, width, height float64) (*bot.Confi
websocket.JSON.Send(ws, bot.NewFailure("generic server error"))
return nil, err
}
log.Printf("gameparam: %+v", gameParam)
switch clientid.Type {
case "robot":
var conf bot.Config
log.Printf("got here?")
for {
log.Printf("%s Waiting for client to send conf ...", id)
err = websocket.JSON.Receive(ws, &conf)
log.Printf("conf received: %+v", conf)
if err != nil {
return nil, err
}