Esempio n. 1
0
//------------------------------------------------ Game Server Request Proxy
func GSProxy(hostid int32, reader *packet.Packet) (ret []byte) {
	defer helper.PrintPanicStack()

	// read protocol number
	b, err := reader.ReadS16()
	if err != nil {
		log.Println("read protocol error")
		return
	}

	// get handler
	handle := protos.ProtoHandler[b]
	if handle == nil {
		log.Println("service not bind", b)
		return
	}

	// call handler
	start := time.Now()
	ret = handle(hostid, reader)
	end := time.Now()
	log.Printf("code: %v %v TIME:%v\n", b, protos.RCode[b], end.Sub(start))

	return ret
}
Esempio n. 2
0
func PKT_user_archives_info(reader *packet.Packet) (tbl user_archives_info, err error) {
	tbl.F_id, err = reader.ReadS32()
	checkErr(err)
	tbl.F_archives, err = reader.ReadString()
	checkErr(err)
	return
}
Esempio n. 3
0
func PKT_GETLIST(reader *packet.Packet) (tbl GETLIST, err error) {
	tbl.F_A, err = reader.ReadS32()
	checkErr(err)
	tbl.F_B, err = reader.ReadS32()
	checkErr(err)
	return
}
Esempio n. 4
0
func PKT_ID_SCORE(reader *packet.Packet) (tbl ID_SCORE, err error) {
	tbl.F_id, err = reader.ReadS32()
	checkErr(err)
	tbl.F_score, err = reader.ReadS32()
	checkErr(err)
	return
}
Esempio n. 5
0
func PKT_MSG(reader *packet.Packet) (tbl MSG, err error) {
	tbl.F_id, err = reader.ReadS32()
	checkErr(err)
	tbl.F_data, err = reader.ReadBytes()
	checkErr(err)
	return
}
Esempio n. 6
0
func PKT_atk_player_rst_req(reader *packet.Packet) (tbl atk_player_rst_req, err error) {
	tbl.F_rst, err = reader.ReadS32()
	checkErr(err)
	tbl.F_protect_time, err = reader.ReadS32()
	checkErr(err)
	return
}
Esempio n. 7
0
func PKT_seed_info(reader *packet.Packet) (tbl S_seed_info, err error) {
	tbl.F_client_send_seed, err = reader.ReadS32()
	checkErr(err)

	tbl.F_client_receive_seed, err = reader.ReadS32()
	checkErr(err)

	return
}
Esempio n. 8
0
func PKT_error_info(reader *packet.Packet) (tbl S_error_info, err error) {
	tbl.F_code, err = reader.ReadS32()
	checkErr(err)

	tbl.F_msg, err = reader.ReadString()
	checkErr(err)

	return
}
Esempio n. 9
0
func PKT_talk(reader *packet.Packet) (tbl talk, err error) {
	tbl.F_user, err = reader.ReadString()
	checkErr(err)

	tbl.F_msg, err = reader.ReadString()
	checkErr(err)

	return
}
Esempio n. 10
0
func PKT_LIST(reader *packet.Packet) (tbl LIST, err error) {
	narr, err2 := reader.ReadU16()
	checkErr(err2)
	tbl.F_items = make([]ID_SCORE, narr)
	for i := 0; i < int(narr); i++ {
		tbl.F_items[i], err = PKT_ID_SCORE(reader)
	}
	return
}
Esempio n. 11
0
func PKT_LOGIN_ACK(reader *packet.Packet) (tbl LOGIN_ACK, err error) {
	tbl.F_success, err = reader.ReadBool()
	checkErr(err)

	tbl.F_groupmsgmax, err = reader.ReadU32()
	checkErr(err)

	return
}
Esempio n. 12
0
func PKT_PROTECT(reader *packet.Packet) (tbl PROTECT, err error) {
	tbl.F_id, err = reader.ReadS32()
	checkErr(err)

	tbl.F_protecttime, err = reader.ReadS64()
	checkErr(err)

	return
}
Esempio n. 13
0
func PKT_pve_list(reader *packet.Packet) (tbl pve_list, err error) {
	narr, err2 := reader.ReadU16()
	checkErr(err2)
	tbl.F_items = make([]pve_list_item, narr)
	for i := 0; i < int(narr); i++ {
		tbl.F_items[i], err = PKT_pve_list_item(reader)
	}
	return
}
Esempio n. 14
0
func PKT_pve_list_item(reader *packet.Packet) (tbl pve_list_item, err error) {
	tbl.F_id, err = reader.ReadS32()
	checkErr(err)
	tbl.F_name, err = reader.ReadString()
	checkErr(err)
	tbl.F_rank, err = reader.ReadS32()
	checkErr(err)
	tbl.F_state, err = reader.ReadS32()
	checkErr(err)
	tbl.F_protect_time, err = reader.ReadS32()
	checkErr(err)
	return
}
Esempio n. 15
0
func PKT_INFO(reader *packet.Packet) (tbl INFO, err error) {
	tbl.F_id, err = reader.ReadS32()
	checkErr(err)
	tbl.F_state, err = reader.ReadS32()
	checkErr(err)
	tbl.F_score, err = reader.ReadS32()
	checkErr(err)
	tbl.F_clan, err = reader.ReadS32()
	checkErr(err)
	tbl.F_name, err = reader.ReadString()
	checkErr(err)
	return
}
Esempio n. 16
0
func (p user_snapshot) Pack(w *packet.Packet) {
	w.WriteS32(p.F_uid)
	w.WriteString(p.F_name)
	w.WriteS32(p.F_level)
	w.WriteS32(p.F_current_exp)

}
Esempio n. 17
0
File: proxy.go Progetto: hycxa/gonet
func HandleRequest(reader *packet.Packet) {
	defer PrintPanicStack()
	b, err := reader.ReadS16()
	if err != nil {
		log.Println("read protocol error")
		return
	}

	handle := protos.ProtoHandler[b]
	//DEBUG("=== stats protocal====", b)
	if handle == nil {
		log.Println("service not bind", b)
		return
	}
	handle(reader)
}
Esempio n. 18
0
func PKT_INFO(reader *packet.Packet) (tbl INFO, err error) {
	tbl.F_flag, err = reader.ReadBool()
	checkErr(err)

	tbl.F_id, err = reader.ReadS32()
	checkErr(err)

	tbl.F_state, err = reader.ReadByte()
	checkErr(err)

	tbl.F_score, err = reader.ReadS32()
	checkErr(err)

	tbl.F_protecttime, err = reader.ReadS64()
	checkErr(err)

	return
}
Esempio n. 19
0
func PKT_user_login_info(reader *packet.Packet) (tbl user_login_info, err error) {
	tbl.F_mac_addr, err = reader.ReadString()
	checkErr(err)
	tbl.F_client_version, err = reader.ReadS32()
	checkErr(err)
	tbl.F_new_user, err = reader.ReadByte()
	checkErr(err)
	tbl.F_user_name, err = reader.ReadString()
	checkErr(err)
	return
}
Esempio n. 20
0
func HandleRequest(hostid int32, reader *packet.Packet) []byte {
	defer _HandleError()

	b, err := reader.ReadU16()

	if err != nil {
		log.Println("read protocol error")
	}

	fmt.Println("proto: ", b)
	handle := ProtoHandler[b]
	if handle != nil {
		ret, err := handle(hostid, reader)
		fmt.Println(ret)
		if err == nil {
			return ret
		}
	}

	return nil
}
Esempio n. 21
0
func PKT_ADD_EVENT(reader *packet.Packet) (tbl ADD_EVENT, err error) {
	tbl.F_type, err = reader.ReadS16()
	checkErr(err)

	tbl.F_user_id, err = reader.ReadS32()
	checkErr(err)

	tbl.F_timeout, err = reader.ReadS64()
	checkErr(err)

	tbl.F_params, err = reader.ReadBytes()
	checkErr(err)

	return
}
Esempio n. 22
0
func PKT_user_snapshot(reader *packet.Packet) (tbl user_snapshot, err error) {
	tbl.F_uid, err = reader.ReadS32()
	checkErr(err)

	tbl.F_name, err = reader.ReadString()
	checkErr(err)

	tbl.F_level, err = reader.ReadS32()
	checkErr(err)

	tbl.F_current_exp, err = reader.ReadS32()
	checkErr(err)

	return
}
Esempio n. 23
0
func HandleRequest(hostid int32, reader *packet.Packet, output chan []byte) {
	defer helper.PrintPanicStack()

	seqid, err := reader.ReadU64() // read seqid
	if err != nil {
		log.Println("Read Sequence Id failed.", err)
		return
	}

	b, err := reader.ReadS16()
	if err != nil {
		log.Println("read protocol error")
		return
	}

	handle := ProtoHandler[b]
	if handle != nil {
		ret := handle(hostid, reader)
		if len(ret) != 0 {
			helper.SendChan(seqid, ret, output)
		}
	}
}
Esempio n. 24
0
func PKT_CHGSCORE(reader *packet.Packet) (tbl CHGSCORE, err error) {
	tbl.F_id, err = reader.ReadS32()
	checkErr(err)
	tbl.F_oldscore, err = reader.ReadS32()
	checkErr(err)
	tbl.F_newscore, err = reader.ReadS32()
	checkErr(err)
	return
}
Esempio n. 25
0
func PKT_LOGIN_REQ(reader *packet.Packet) (tbl LOGIN_REQ, err error) {
	tbl.F_id, err = reader.ReadS32()
	checkErr(err)

	tbl.F_group, err = reader.ReadS32()
	checkErr(err)

	tbl.F_groupmsgmax, err = reader.ReadU32()
	checkErr(err)

	return
}
Esempio n. 26
0
func PKT_SET_UPDATE_REQ(reader *packet.Packet) (tbl SET_UPDATE_REQ, err error) {
	tbl.F_key, err = reader.ReadString()
	checkErr(err)

	tbl.F_value, err = reader.ReadString()
	checkErr(err)

	tbl.F_lang, err = reader.ReadString()
	checkErr(err)

	return
}
Esempio n. 27
0
func (p auto_id) Pack(w *packet.Packet) {
	w.WriteS32(p.F_id)

}
Esempio n. 28
0
func PKT_auto_id(reader *packet.Packet) (tbl auto_id, err error) {
	tbl.F_id, err = reader.ReadS32()
	checkErr(err)

	return
}
Esempio n. 29
0
func PKT_INT(reader *packet.Packet) (tbl INT, err error) {
	tbl.F_v, err = reader.ReadS32()
	checkErr(err)

	return
}
Esempio n. 30
0
func PKT_EVENT_ID(reader *packet.Packet) (tbl EVENT_ID, err error) {
	tbl.F_event_id, err = reader.ReadS32()
	checkErr(err)

	return
}