Sending ByteArray from Server to Client results in NetConnection.Call.Failed

View: New views
1 Messages — Rating Filter:   Alert me  

Sending ByteArray from Server to Client results in NetConnection.Call.Failed

by Alexandre Silva-4 :: Rate this Message:

Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.

Hello,

 

 

I’m having some problems sending a ByteArray object from the server to the flash client.

I always get the following error:

 

code = "NetConnection.Call.Failed"

description = "HTTP: Status 404"

details = http://localhost/WebSolutions/RasgoIDNews/FluorineFX/gateway.aspx

level = "error"   

 

The strange thing is that if I return from the server another object instead of FluorineFx.AMF3.ByteArray, like for instance a custom class I have defined with strings and ints everything goes well. If I return a byte[], it won’t be recognized as a ByteArray in Flash (error when casting object: Type Coercion failed: cannot convert (…) to flash.utils.ByteArray), but still doesn’t give me a 404 error!

 

I followed the ByteArray example in FlurioneFx samples… my code is above:

 

Server-side

 

        public FluorineFx.AMF3.ByteArray EchoByteArray(ByteArray byteArray)

        {

            // Transfere de ByteArray para MemoryStream

            uint length = byteArray.Length;

            byte[] bytes = new byte[length];

            byteArray.ReadBytes(bytes, 0, length);

            MemoryStream stream = new MemoryStream(bytes);

 

            // Cria a imagem

            Image image = Bitmap.FromStream(stream);

 

            // salvar imagem

            string filePath = HttpContext.Current.Server.MapPath("_lib/") + DateTime.Now.Ticks + ".bmp";

            image.Save(filePath);

            //Bitmap bmp = (Bitmap)image;

 

            // dispose objs

            stream.Dispose();

            image.Dispose();

 

            //must include openCV DLLs in context project (FluorineFX Website)

            Image<Bgr, Byte> imageCV = new Image<Bgr, Byte>(filePath);

 

            return BitmapToByteArray(imageCV.Bitmap);

        }

 

        private FluorineFx.AMF3.ByteArray BitmapToByteArray(Bitmap bitmap)

        {

            try

            {

                ByteArray ba;

                using (MemoryStream ms = new MemoryStream())

                {

                    bitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Png);

                    ba = new ByteArray(ms);

                }

                return ba;

            }

            catch (Exception ex)

            {

                return new ByteArray();

            }

        }

 

 

However in client-side, i have some differences from the example, but i can’t find anything that might be wrong:

 

Constructor:

                  connection = new NetConnection();

                  connection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);

                  connection.objectEncoding = ObjectEncoding.AMF3;

                  connection.connect(RasgoTextCloud.SERVER_URL);

 

(…)

 

Method than invoke remote method…

                  //test byte array

                  connection.call("RasgoFaceDetectionCV.FaceRecognition.EchoByteArray",

                        responder, photoBytes);

(…)

 

Response handler:

            private function onResult_takePhoto(result:Object):void

            {

                  var byteArr:ByteArray = result as ByteArray;

                  bitmapLoader.loadBytes(byteArr);  

}

 

 

Like I said,  this works OK if the object that goes from server to client is not a FluorineFx.AMF3.ByteArray.

 

Can anyone help me out? Why am I getting a 404 http error when trying to pass a ByteArray?

 

As an additional note, if I decompose manually the bitmap into an array of bytes or uint, and do the same on the client side everthing works well… but I would like to take advantage of the Fluorine capabilities of sending a ByteArray…

 

Thanks

 

Alexandre Silva

asilva@...

 


_______________________________________________
fluorine mailing list
fluorine@...
http://fluorine.thesilentgroup.com/mailman/listinfo/fluorine_fluorine.thesilentgroup.com