func newAmfBytesWriter(name string) (*amf0.Writer, error) { w := amf0.NewWriter(xio.NewPacketWriter(nil)) if err := w.Write8(0x0f); err != nil { return nil, errors.New("message.amf.write code") } if err := w.Write8(0); err != nil { return nil, errors.New("message.amf.write useless1") } if err := w.Write32(0); err != nil { return nil, errors.New("message.amf.write useless2") } if err := w.WriteString(name); err != nil { return nil, errors.New("message.amf.write name") } return w, nil }
func newAmfMessageWriter(name string, callback float64) (*amf0.Writer, error) { w := amf0.NewWriter(xio.NewPacketWriter(nil)) if err := w.Write8(0x14); err != nil { return nil, errors.New("message.amf.write code") } if err := w.Write32(0); err != nil { return nil, errors.New("message.amf.write useless") } if err := w.WriteString(name); err != nil { return nil, errors.New("message.amf.write name") } if err := w.WriteNumber(callback); err != nil { return nil, errors.New("message.amf.write callback") } if err := w.WriteNull(); err != nil { return nil, errors.New("message.amf.write null") } return w, nil }