//------------------------------------------------ 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 }
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 }
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 }
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 }
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 }
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 }
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 }
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 }
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 }
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 }
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 }
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 }
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 }
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 }
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 }
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) }
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) }
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 }
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 }
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 }
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 }
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 }
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) } } }
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 }
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 }
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 }
func (p auto_id) Pack(w *packet.Packet) { w.WriteS32(p.F_id) }
func PKT_auto_id(reader *packet.Packet) (tbl auto_id, err error) { tbl.F_id, err = reader.ReadS32() checkErr(err) return }
func PKT_INT(reader *packet.Packet) (tbl INT, err error) { tbl.F_v, err = reader.ReadS32() checkErr(err) return }
func PKT_EVENT_ID(reader *packet.Packet) (tbl EVENT_ID, err error) { tbl.F_event_id, err = reader.ReadS32() checkErr(err) return }