views:

94

answers:

1

I am receiving AMF3 serialized objects via a socket connection, thus I have byte arrays of these objects.

What is the officially designated way to deserialize these byte arrays to an ASObject or dictionary with FluorineFX?

The most promising of my tries

MemoryStream ms = new MemoryStream(data, 0, recv);
AMFReader input = new AMFReader(ms);
var t = input.ReadAMF3Object();

results in null-objects. If i use ReadASObject instead, i get an index out of bounds access violation.

A: 

How about something like:

public object ReadAmfData(byte[] data)
{
   MemoryStream stream = new MemoryStream(data);
   AMFDeserializer deserializer = new AMFDeserializer(stream);

   try
   {
      return deserializer.ReadAMF3Data();
   }
   catch
   ...

For Wcf services, you could have a look at the WcfFlashRemoting project too, we've been using it for a while and it more than does the job for us.

theburningmonk
@theburningmonk Thanks for your reply. Same problem: it just returns `null`
Mef
@Mef - have you checked the data itself with something like Charles and see if it's correct? Another thing to check is if the object being deserialized is mapped correctly between the flash and C# version. One thing that has stung us before was the namespace, which has to match exactly.
theburningmonk
@theburningmonk silly me. You just have to strip the first 4 bytes away cause they contain the packet length and `AMFReader` doesn't like that. But i'll accept your anwser anyways :D
Mef