server/spectator.go

22 lines
327 B
Go
Raw Normal View History

2013-08-19 22:23:35 -07:00
package main
import (
2013-09-03 23:26:40 -07:00
"bitbucket.org/hackerbots/bot"
2013-08-19 22:23:35 -07:00
"code.google.com/p/go.net/websocket"
)
type Spectator struct {
2013-08-19 23:44:00 -07:00
ws *websocket.Conn
2013-09-03 23:26:40 -07:00
send chan *bot.Boardstate
2013-08-19 22:23:35 -07:00
}
func (s *Spectator) sender() {
for things := range s.send {
err := websocket.JSON.Send(s.ws, *things)
if err != nil {
break
}
}
s.ws.Close()
}