Exemplo n.º 1
0
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))
}
Exemplo n.º 2
0
// 只创建了用户对象的原始用户
func RawUserHandler(ses *netdef.Session, c netdef.IPacketContext) {

	u := GetUser(ses)

	if u == nil {
		c.CancelRoute()
		return
	}

	c.Map(u)
}
Exemplo n.º 3
0
// 进入游戏前的用户
func AccountHandler(ses *netdef.Session, c netdef.IPacketContext) {

	u := GetUser(ses)

	if u == nil || !u.VerifyOK || u.EnterGameOK {
		c.CancelRoute()
		return
	}

	c.Map(u)
}
Exemplo n.º 4
0
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)
}
Exemplo n.º 5
0
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)
	}
}