예제 #1
0
// EncodeMsg implements msgp.Encodable
func (z *Packet) EncodeMsg(en *msgp.Writer) (err error) {
	// map header, size 4
	// write "type"
	err = en.Append(0x84, 0xa4, 0x74, 0x79, 0x70, 0x65)
	if err != nil {
		return err
	}
	err = en.WriteByte(z.pType)
	if err != nil {
		return
	}
	// write "id"
	err = en.Append(0xa2, 0x69, 0x64)
	if err != nil {
		return err
	}
	err = en.WriteInt(z.id)
	if err != nil {
		return
	}
	// write "event"
	err = en.Append(0xa5, 0x65, 0x76, 0x65, 0x6e, 0x74)
	if err != nil {
		return err
	}
	err = en.WriteString(z.eventName)
	if err != nil {
		return
	}
	// write "payload"
	err = en.Append(0xa7, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64)
	if err != nil {
		return err
	}
	err = en.WriteBytes(z.payload)
	if err != nil {
		return
	}
	return
}