Hi,

How can we decode AMF3 Object in Flex coming from a socket. We have a
python Socket server which encodes data as AMF3.

First I am trying to read a bytearray from socket and then trying to
read the object from it. But it says "End of the file is reached" near
the statement " obj = ba.readObject();". Below is my code :


private function connect():void
                        {
                                socket = new Socket();
                                socket.connect(host, port);
                                socket.addEventListener(Event.CONNECT, 
onConnect);
                                socket.addEventListener(Event.CLOSE, onClose);
                                socket.addEventListener(IOErrorEvent.IO_ERROR, 
onError);
                                
socket.addEventListener(ProgressEvent.SOCKET_DATA, onProgress);
                        }

private function onConnect(event:Event):void
                        {

                                if (socket.connected) {

                                        isConnected = true;
                                        trace("connected");
                                        lblconn.setStyle("color", "#5DA237");
                                        lblconn.text = "Connected";
                                }
                        }

                        private function onClose(event:Event):void
                        {
                                lblconn.setStyle("color", "#FF0000");
                                lblconn.text = "Not Connected";
                                isConnected = false;
                        }

                        private function onError(event:IOErrorEvent):void
                        {
                                Alert.show(event.text);
                                lblconn.setStyle("color", "#FF0000");
                                lblconn.text = "Connection Error";
                        }

                        private function onProgress(event:ProgressEvent):void
                        {
                                var ba:ByteArray = new ByteArray();
                                var ba1:ByteArray = new ByteArray();
                                var i:int = 1024;
                                var obj:Object=new Object();
                                var numbytes :int =0;
                                var data1:String = "";



                                socket.readBytes(ba,0, socket.bytesAvailable);
                                Alert.show("Bytes read "+ba.toString());
                                socket.close();
                                obj = ba.readObject();              //Getting 
End of the file is
reached exception here



                        }

Please suggest me if there is any other way to deocode AMF3 from a
byteArray coming from a socket. Please help me  its very very urgent

-- 
You received this message because you are subscribed to the Google Groups "Flex 
India Community" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/flex_india?hl=en.

Reply via email to