Update to new protocol (Update)
This commit is contained in:
@@ -31,7 +31,7 @@ type Client struct {
|
||||
Player Player
|
||||
Game server.GameParam
|
||||
|
||||
boardstate server.Boardstate
|
||||
boardstate *server.Boardstate
|
||||
enc encoder
|
||||
dec decoder
|
||||
ws *websocket.Conn
|
||||
@@ -164,16 +164,14 @@ func (c *Client) Negociate(clientType string) (err error) {
|
||||
func (c *Client) Play() error {
|
||||
log.Printf("%s: starting loop", c.Name)
|
||||
|
||||
bs := &server.Boardstate{}
|
||||
var err error
|
||||
for {
|
||||
err = c.dec.Decode(&c.boardstate)
|
||||
err = c.dec.Decode(bs)
|
||||
if err != nil {
|
||||
return errors.New(fmt.Sprintf("%s: Connection likely lost: %s", c.Name, err))
|
||||
}
|
||||
c.Player.Recv(&c.boardstate)
|
||||
|
||||
instruction := c.Player.Instruction()
|
||||
err = c.enc.Encode(instruction)
|
||||
err = c.enc.Encode(c.Player.Update(bs))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user