Example #1
0
func DecodeMsg(data []byte) (api int16, v interface{}) {
	defer func() {
		if err := recover(); err != nil {
			fmt.Printf("DECODE MSG ERR: %v %v", data, err)
			api = -1
			v = nil
		}
	}()

	//	解包协议 package protocol
	api, payload := protocol.DecodeMsg(&data)
	return api, payload
}
Example #2
0
func parseMsg(data *[]byte, session *Session) *NetMsg {
	defer func() {
		if err := recover(); err != nil {
			fmt.Printf("DECODE MSG ERR: %p %v %v", session, data, err)
		}
	}()

	api, payload := protocol.DecodeMsg(data)
	return &NetMsg{
		Api:     api,
		Payload: payload,
		Session: session,
	}
}