Esempio n. 1
0
func forwardEvent(evtName string) func(e events.Event) interface{} {
	return func(e events.Event) interface{} {
		u := events.GetUserId(e)
		// forward to XNA
		helper.ToXna(evtName, u.Id)
		return nil
	}
}
Esempio n. 2
0
func onUserHeartbeat(e events.Event) interface{} {
	u := events.GetUserId(e)

	score := float64(time.Now().Unix())

	heartbeat := r.Z{
		score,
		strconv.Itoa(u.Id),
	}

	db.Redis.ZAdd("global:clients", heartbeat)

	return nil
}
Esempio n. 3
0
func onUserAttack(e events.Event) interface{} {
	u := events.GetUserId(e)

	userTeamKey := fmt.Sprintf("uid:%v:team", u.Id)
	teamId, _ := strconv.Atoi(db.Redis.Get(userTeamKey).Val())

	// forward to XNA
	msg := struct {
		Name string `tcp:"name"`
		Id   int    `tcp:"id"`
		UserId int 	`tcp:"userId"`
	}{"collector:attack", teamId, u.Id}
	network.TcpClients.Broadcast <- msg
	//helper.ToXna("collector:attack", teamId)
	return nil
}