本文整理匯總了Golang中core/netdef.IPacketContext類的典型用法代碼示例。如果您正苦於以下問題:Golang IPacketContext類的具體用法?Golang IPacketContext怎麽用?Golang IPacketContext使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了IPacketContext類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: injectResponseHandler
func injectResponseHandler(c netdef.IPacketContext, codec netdef.IPacketCodec, ses *netdef.Session, msg *coredef.RemoteCallREQ) {
c.MapTo(&rpcResponse{
codec: codec,
req: msg,
ses: ses,
}, (*IResponse)(nil))
}
示例2: RawUserHandler
// 隻創建了用戶對象的原始用戶
func RawUserHandler(ses *netdef.Session, c netdef.IPacketContext) {
u := GetUser(ses)
if u == nil {
c.CancelRoute()
return
}
c.Map(u)
}
示例3: AccountHandler
// 進入遊戲前的用戶
func AccountHandler(ses *netdef.Session, c netdef.IPacketContext) {
u := GetUser(ses)
if u == nil || !u.VerifyOK || u.EnterGameOK {
c.CancelRoute()
return
}
c.Map(u)
}
示例4: MsgAdapter_RelayMessageACK
func MsgAdapter_RelayMessageACK(pkt *netdef.Packet, c netdef.IPacketContext) {
msg := &RelayMessageACK{}
err := proto.Unmarshal(pkt.Data, msg)
if err != nil {
log.Printf("[RelayMessageACK] unmarshaling error:\n", err)
return
}
c.Map(msg)
}
示例5: CallHandlers
func (self *EventDispatcher) CallHandlers(id int, c netdef.IPacketContext) {
if self.capturePanic {
defer func() {
if err := recover(); err != nil {
log.Printf("id: %x panic: %v", id, err) // 這裏的err其實就是panic傳入的內容,55
}
}()
}
em, ok := self.eventHandlers[id]
if ok && len(em) > 0 {
c.CallHandlers(em)
}
}