Esempio n. 1
0
File: hello.go Progetto: hundt/poker
func broadcastState(c appengine.Context, g *poker.GameState) error {
	for _, watcher := range g.Watchers {
		json, err := g.ClientState(watcher).JSON()
		if err != nil {
			return err
		}
		err = channel.Send(c, watcher+g.Id(), json)
		if err != nil {
			c.Errorf("sending Game: %v", err)
		}
	}
	return nil
}
Esempio n. 2
0
File: hello.go Progetto: hundt/poker
func addWatcher(gs *poker.GameState, uid string) bool {
	for _, watcher := range gs.Watchers {
		if watcher == uid {
			return false
		}
	}
	gs.Watchers = append(gs.Watchers, uid)
	return true
}