sendConnectPacket() now encodes required link info in one go using amf.Encode().

This commit is contained in:
scruzin 2019-01-20 07:33:43 +10:30
parent adfb87dcf9
commit 42be87d98a
1 changed files with 7 additions and 15 deletions

View File

@ -276,26 +276,18 @@ func sendConnectPacket(c *Conn) error {
return err
}
enc[0] = amf.TypeObject
enc = enc[1:]
enc, err = amf.EncodeNamedString(enc, avApp, c.link.app)
if err != nil {
return err
// required link info
info := amf.Object{Properties: []amf.Property{
amf.Property{Type: amf.TypeString, Name: avApp, String: c.link.app},
amf.Property{Type: amf.TypeString, Name: avType, String: avNonprivate},
amf.Property{Type: amf.TypeString, Name: avTcUrl, String: c.link.url}},
}
enc, err = amf.EncodeNamedString(enc, avType, avNonprivate)
if err != nil {
return err
}
enc, err = amf.EncodeNamedString(enc, avTcUrl, c.link.url)
if err != nil {
return err
}
enc, err = amf.EncodeInt24(enc, amf.TypeObjectEnd)
enc, err = amf.Encode(&info, enc)
if err != nil {
return err
}
// add auth string, if any
// optional link auth info
if c.link.auth != "" {
enc, err = amf.EncodeBoolean(enc, c.link.flags&linkAuth != 0)
if err != nil {