[Red5devs] io.Datatypes vs. io.amf.AMF
Luke Hubbard (email@example.com)
king.selassie at gmail.com
Tue Feb 7 23:29:09 EST 2006
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.
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
> 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.
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...
More information about the Red5devs