[Red5devs] io.Datatypes vs. io.amf.AMF

Luke Hubbard (luke@codegent.com) king.selassie at gmail.com
Tue Feb 7 23:29:09 EST 2006


Hi Joachim,

Good question, the reason they are not the same is io.DataTypes contains
generic object serialization types. This is mapped to AMF types in the amf
input and output objects. Why? Well 80% of object serialization code is the
same no matter what the format, looping over object properties, writing a
list, writing a map, etc. Having a general datatypes will allow us to add
other formats in the future without changing the serializer and
deserializer. Possible formats.. json, xml, amf 3, etc.

-- Luke

On 2/8/06, Joachim Bauch <jojo at struktur.de> wrote:
>
> Hi Luke,
>
> I'm wondering why the ids of the datatypes in org.red5.server.io.DataTypes
> differ from the AMF types in org.red5.server.io.AMF.  With the current
> code,
> you can't use the Serializer / Deserializer in the io package because it
> tries to load other types than the saved ones.
>
> ...or maybe I'm missing something?
>
> My code looks like this:
>
> import org.red5.server.io.amf.Input;
> import org.red5.server.io.amf.Output;
> import org.red5.server.io.Deserializer;
> import org.red5.server.io.Serializer;
>
> // buf is a mina ByteBuffer
> Output out = new Output(buf);
> Serializer serializer = new Serializer();
> out.writeString("Hello world.");
> // data is a HashMap
> serializer.writeMap(out, data);
> // do other stuff
> Input in = new Input(buf);
> Deserializer deserializer = new Deserializer();
> String str = in.readString();
> Map data = (Map) deserializer.deserialize(in);
>
> This last line leads to ClassCastException because the deserializer loads
> a double instead of the expected map.
>
> I consider changing the DataTypes to use the definitions from AMF.
>
> Greetings,
>    Joachim
>



--
Google != Do no evil. Big G, I know you read all my emails. What the hell is
going on with the China censorship decision. Have you completely lost it! If
you like me are not happy about this lack of principals email
gblog at google.com and add an angry signature to your gmail.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://osflash.org/pipermail/red5devs_osflash.org/attachments/20060208/da185901/attachment.htm


More information about the Red5devs mailing list