示例#1
0
文件: hello.go 项目: 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
}
示例#2
0
文件: hello.go 项目: 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
}