예제 #1
0
// DecodeMsg implements msgp.Decodable
func (z *Packet) DecodeMsg(dc *msgp.Reader) (err error) {
	var field []byte
	_ = field
	var isz uint32
	isz, err = dc.ReadMapHeader()
	if err != nil {
		return
	}
	for isz > 0 {
		isz--
		field, err = dc.ReadMapKeyPtr()
		if err != nil {
			return
		}
		switch msgp.UnsafeString(field) {
		case "type":
			z.pType, err = dc.ReadByte()
			if err != nil {
				return
			}
		case "id":
			z.id, err = dc.ReadInt()
			if err != nil {
				return
			}
		case "event":
			z.eventName, err = dc.ReadString()
			if err != nil {
				return
			}
		case "payload":
			z.payload, err = dc.ReadBytes(z.payload)
			if err != nil {
				return
			}
		default:
			err = dc.Skip()
			if err != nil {
				return
			}
		}
	}
	return
}