You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

37 lines
658 B

package main
import (
"code.google.com/p/go.net/websocket"
"log"
)
type Spectator struct {
ws *websocket.Conn
send chan Message
Id string
}
func (s *Spectator) sender() {
log.Printf("%s: sender launched", s.Id)
for things := range s.send {
err := websocket.JSON.Send(s.ws, things)
if err != nil {
break
}
}
s.ws.Close()
log.Printf("%s: spectator sender close", s.Id)
}
func (s *Spectator) recv() {
for {
var msg interface{}
err := websocket.JSON.Receive(s.ws, &msg)
if err != nil {
log.Printf("%s: problem receiving JSON from spectator: %s", s.Id, err)
break
}
}
log.Printf("%s: recv close", s.Id)
s.ws.Close()
}