Documentation
¶
Index ¶
- Constants
- func AmfBooleanDecode(data []byte) (bool, int, error)
- func AmfBooleanEncode(b bool) []byte
- func AmfDateEncode(date AmfDate) []byte
- func AmfLongStringDecode(data []byte) (string, int, error)
- func AmfLongStringEncode(s string) []byte
- func AmfNull() []byte
- func AmfNumberDecode(data []byte) (float64, int, error)
- func AmfNumberEncode(num float64) ([]byte, error)
- func AmfObjEnd() []byte
- func AmfRefDecode(data []byte) (uint16, int, error)
- func AmfRefEncode(ref uint16) []byte
- func AmfStringDecode(data []byte) (string, int, error)
- func AmfStringEncode(s string) []byte
- func AmfUTF8Decode(data []byte) (string, int, error)
- func AmfUTF8Encode(s string) []byte
- func AmfUTF8LongDecode(data []byte) (string, int, error)
- func AmfUTF8LongEncode(s string) []byte
- func AmfUndefined() []byte
- func AmfXmldocEncode(doc AmfXmldoc) []byte
- type AmfArray
- type AmfCodec
- func (c *AmfCodec) AmfArrayDecode(data []byte) (*AmfArray, int, error)
- func (c *AmfCodec) AmfArrayEncode(arr *AmfArray) ([]byte, error)
- func (c *AmfCodec) AmfECMADecode(data []byte) (*AmfECMA, int, error)
- func (c *AmfCodec) AmfECMAEncode(val *AmfECMA) ([]byte, error)
- func (c *AmfCodec) AmfObjDecode(data []byte) (*AmfObj, int, error)
- func (c *AmfCodec) AmfObjEncode(obj *AmfObj) ([]byte, error)
- func (c *AmfCodec) Clear()
- func (c *AmfCodec) Decode(data []byte) (interface{}, int, error)
- func (c *AmfCodec) Encode(val interface{}) ([]byte, error)
- func (c *AmfCodec) GetId(val interface{}) (uint16, error)
- func (c *AmfCodec) GetObj(id uint16) (interface{}, error)
- func (c *AmfCodec) Set(val interface{})
- type AmfDate
- type AmfECMA
- type AmfMarker
- type AmfObj
- type AmfObjProp
- type AmfXmldoc
Constants ¶
const ( AMF_NUMBER = 0x00 AMF_BOOLEAN = 0x01 AMF_STRING = 0x02 AMF_OBJECT = 0x03 // not supported AMF_MOVIECLIP = 0x04 AMF_NULL = 0x05 AMF_UNDEFINED = 0x06 AMF_REFERENCE = 0x07 AMF_ECMA = 0x08 AMF_OBJEND = 0x09 AMF_STRICTARR = 0x0a AMF_DATE = 0x0b AMF_LONGSTRING = 0x0c // not supported AMF_UNSUP = 0x0d AMF_RECORDSET = 0x0e AMF_XMLDOC = 0x0f AMF_TYPEDOBJ = 0x10 // switch to AMF3 AVMPLUS_OBJ_MARKER = 0x11 )
const (
AMF_STRING_MAXLEN = 65535
)
Variables ¶
This section is empty.
Functions ¶
func AmfBooleanEncode ¶
func AmfDateEncode ¶
func AmfLongStringEncode ¶
func AmfNumberEncode ¶
func AmfRefEncode ¶
func AmfStringEncode ¶
func AmfUTF8Encode ¶
If the string is longer than this, it will be truncated to `AMF_STRING_MAXLEN`
func AmfUTF8LongEncode ¶
func AmfUndefined ¶
func AmfUndefined() []byte
func AmfXmldocEncode ¶
Types ¶
type AmfCodec ¶
type AmfCodec struct {
// contains filtered or unexported fields
}
func NewAmfCodec ¶
func NewAmfCodec() *AmfCodec
func (*AmfCodec) AmfArrayDecode ¶
func (*AmfCodec) AmfECMADecode ¶
func (*AmfCodec) AmfObjEncode ¶
Used to encode an object. Because object passed in is strongly typed, we encode into the TypedObject format. Because we're using `reflect`, all fields must be exported, the unexported fields will be ignored.
func (*AmfCodec) Decode ¶
Notice both Null and Undefined are decoded as `nil` in golang. Also, when encountered with the following types: 1. AMF_MOVIECLIP 2. AMF_UNDEFINED 3. AMF_UNSUP 4. AMF_RECORDSET Decode will return a `Unsupported type` error. Consider handling these types gracefully, instead of panicking.
func (*AmfCodec) Encode ¶
If a type is implemented because primitive types are not sufficient, then that type would be implemented as a struct. When passing such a type, they should be passed as a pointer. Specifically, the following types needs to be passed as pointers: 1. AmfObj 2. AmfECMA 3. AmfArray Passing primitive types will result in the following encoding: uint*, int* -> float64 -> AmfNumber float64 -> AmfNumber bool -> AmfBoolean string -> AmfStr | AmfLongStr nil -> AmfNull Some types can never come out of Encode():
x -> AmfMovieclip (not used when encoding) x -> AmfUndefined (not used when encoding) x -> AmfUnsupported (not used when encoding) x -> AmfRecordset (not used when encoding)
type AmfObj ¶
type AmfObj struct { Name string Props []AmfObjProp // For easy access. To access, call PopulatePropMp() first. PropMp map[string]interface{} }
func (*AmfObj) PopulatePropMp ¶
func (obj *AmfObj) PopulatePropMp()
Call this before accessing PropMp
type AmfObjProp ¶
type AmfObjProp struct { Key string Value interface{} }