Exemplo n.º 1
0
func P_forward_req(hostid int32, pkt *packet.Packet) ([]byte, error) {
	defer func() {
		if x := recover(); x != nil {
			log.Println("forward packet error")
		}
	}()

	tbl, _ := PKT_MSG(pkt)

	// if user is online, send to the user, or else send to redis
	state := ranklist.State(tbl.F_id)
	host := ranklist.Host(tbl.F_id)

	fmt.Println(tbl.F_id, tbl.F_data)
	if state&ranklist.ONLINE != 0 {
		_server_lock.RLock()
		ch := _servers[host] // forwarding request
		_server_lock.RUnlock()

		ch <- tbl.F_data
	} else {
		// TODO : add redis
	}

	return nil, nil
}
Exemplo n.º 2
0
func P_getinfo_req(hostid int32, pkt *packet.Packet) ([]byte, error) {
	tbl, _ := PKT_ID(pkt)
	ret := INFO{}
	ret.F_id = tbl.F_id
	ret.F_state = ranklist.State(tbl.F_id)
	ret.F_score = ranklist.Score(tbl.F_id)
	ret.F_clan = ranklist.Score(tbl.F_id)
	ret.F_protecttime = ranklist.ProtectTime(tbl.F_id)
	ret.F_name = ranklist.Name(tbl.F_id)
	return packet.Pack(Code["getinfo_ack"], ret, nil), nil
}