diff --git a/player.go b/player.go index f79a8c1..0882ffa 100644 --- a/player.go +++ b/player.go @@ -2,6 +2,7 @@ package main import ( "code.google.com/p/go.net/websocket" + "encoding/json" "log" ) @@ -16,7 +17,8 @@ type player struct { func (p *player) sender() { log.Printf("%s: sender launched", p.Id) for things := range p.send { - err := websocket.JSON.Send(p.ws, things) + enc := json.NewEncoder(p.ws) + err := enc.Encode(things) if err != nil { break } @@ -30,8 +32,8 @@ func (p *player) recv() { // XXX: need to mark myself as having received something, also binding // such action to a particular game turn ID var msgs map[string]Instruction - err := websocket.JSON.Receive(p.ws, &msgs) - + dec := json.NewDecoder(p.ws) + err := dec.Decode(&msgs) if err != nil { // TODO: perhaps we could be a bit more precise in the handling of // this 'error' by selecting on some kill signal channel and this