Example #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
}
Example #2
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
}
Example #3
0
File: proxy.go Project: 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)
}
Example #4
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)
		}
	}
}