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 }
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 }