本文整理匯總了Golang中misc/packet.Packet.ReadS16方法的典型用法代碼示例。如果您正苦於以下問題:Golang Packet.ReadS16方法的具體用法?Golang Packet.ReadS16怎麽用?Golang Packet.ReadS16使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類misc/packet.Packet
的用法示例。
在下文中一共展示了Packet.ReadS16方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: GSProxy
//------------------------------------------------ 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
}
示例2: PKT_ADD_EVENT
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
}
示例3: HandleRequest
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)
}
示例4: HandleRequest
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)
}
}
}