ExRTMP.AMF0 (RTMP Server and Client v0.4.1)
View SourceModule responsible for parsing and serializingf AMF0 data.
Summary
Types
Functions
Parses the amf0 encoded binary,
The result is a list of decoded items.
iex> ExRTMP.AMF0.parse(<<1, 1, 2, 0, 5, 104, 101, 108, 108, 111, 5>>) [true, "hello", nil]
iex> ExRTMP.AMF0.parse(<<3, 0, 3, 107, 101, 121, 2, 0, 5, 118, 97, 108, 117, 101, 0, 0, 9>>) [%{"key" => "value"}]
iex> ExRTMP.AMF0.parse(<<8, 0, 0, 0, 1, 0, 3, 107, 101, 121, 2, 0, 5, 118, 97, 108, 117, 101, 0, 0, 9>>) [%{"key" => "value"}]
Serializes the given value into amf0 format.
iex> ExRTMP.AMF0.serialize(true) <<1, 1>>
iex> ExRTMP.AMF0.serialize(false) <<1, 0>>
iex> ExRTMP.AMF0.serialize(nil) <<5>>
iex> ExRTMP.AMF0.serialize(3.14) <<0, 64, 9, 30, 184, 81, 235, 133, 31>>
iex> ExRTMP.AMF0.serialize("hello") <<2, 0, 5, 104, 101, 108, 108, 111>>
iex> ExRTMP.AMF0.serialize(:hello) <<2, 0, 5, 104, 101, 108, 108, 111>>
iex> ExRTMP.AMF0.serialize(%{"key" => "value"}) |> IO.iodata_to_binary() <<3, 0, 3, 107, 101, 121, 2, 0, 5, 118, 97, 108, 117, 101, 0, 0, 9>>
iex> ExRTMP.AMF0.serialize({:ecma_array, %{"key" => "value"}}) |> IO.iodata_to_binary() <<8, 0, 0, 0, 1, 0, 3, 107, 101, 121, 2, 0, 5, 118, 97, 108, 117, 101, 0, 0, 9>>