2013-08-19 22:23:35 -07:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"code.google.com/p/go.net/websocket"
|
2013-10-20 20:54:19 -07:00
|
|
|
"log"
|
2013-08-19 22:23:35 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
type Spectator struct {
|
2013-08-19 23:44:00 -07:00
|
|
|
ws *websocket.Conn
|
2013-11-13 22:24:54 -08:00
|
|
|
send chan Message
|
2013-08-19 22:23:35 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Spectator) sender() {
|
|
|
|
for things := range s.send {
|
2013-11-13 22:24:54 -08:00
|
|
|
err := websocket.JSON.Send(s.ws, things)
|
2013-08-19 22:23:35 -07:00
|
|
|
if err != nil {
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
s.ws.Close()
|
2013-10-20 20:54:19 -07:00
|
|
|
log.Printf("Spectator sender close")
|
2013-08-19 22:23:35 -07:00
|
|
|
}
|