Problem with using AMF3 Output:

When I use the IO classes the bytes don't seem to be written out
right in AMF3 and the client fails a range check during marshalling

Side Note:

Once the message is marshalled from AMF0 performance is the same for
standard Actionscript object right?
The main reason I am doing this is so we can get solid sort
performance.  If AMF0 beats XML for simple update
of rows in a DataGrid I won't loose too much sleep.

By the way, the Swerve Framework is open source and provides a simple
REST API in and arbitrary result types out,
like text, XML, binary.  It also has a simple topic based streaming
API that can be used for messaging.
The server keeps the connection open for 60 seconds and sleeps in
100ms intervals.  There is more magic, but you can
check it out at www.swervespot.org.  I'm trying to wrap up a chat
example that demos all the features.
Swerve has a small AS3 set of client classes and a full stack Java
server designed to get the job done fast.  You can
currently take a look at the code by accessing SVN. I provide a link
on the site.

Back to my problem


Java Code:

A simple ChatUser POJO is passed in.
The only piece that is variable on the serverside is the Output import

import org.apache.mina.common.ByteBuffer;
import org.red5.io.object.Serializer;

import org.red5.io.amf.Output; //works
                or
import org.red5.io.amf3.Output; //doesn't work

Bytes are streamed over HttpServletResponse.getOutputstream()



public  static byte [] createAMFBytes(Object data) throws IOException {
                ByteBuffer buffer = ByteBuffer.allocate(1024);
                buffer.setAutoExpand(true);
                
                Output out = new Output(buffer);
                Serializer serializer = new Serializer();
                
                int size;
                byte [] bytes;
                if (serializer.writeComplex(out, data)){
                        size = buffer.position();
                        bytes = new byte[size];
                        buffer.clear();
                        buffer.get(bytes,0,bytes.length);
                        return  bytes;
                        
                }
                
                return null;
                
        }


Actionscript Code:


Results read using URLStream and copied to a new ByteArray
Only thing that is variable on the clientside is the objectencoding

private function membersResult(event:ResultEvent):void {
                        var array:ByteArray = ByteArray(event.result.msg);
                        array.objectEncoding = 3;
                        try {
                        chatStr += "\n" + 
ObjectUtil.toString(array.readObject());
                        }catch (error:Error){
                                trace(error.getStackTrace());
                        return;         
        }
}

Result with AMF0 on client:



(Object)#0
  currentRoom = "APPLE"
  joined = Fri Jun 15 12:34:22 GMT-0400 2007
  msgSent = 0
  user = "sadada"

Result with AMF3 on client:

RangeError: Error #2006: The supplied index is out of bounds.
        at flash.utils::ByteArray/readObject()
        at 
ChatForm/ChatForm::membersResult()[D:\Data\Projects\SourceForge\swerve-sample\src\flex\ChatForm.mxml:109]
        at 
flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
        at flash.events::EventDispatcher/dispatchEvent()
        at 
BusManager/publish()[D:\Data\Projects\SourceForge\swerve-sample\src\flex\BusManager.as:29]
        at 
RESTStreamManager/RESTStreamManager::publish()[D:\Data\Projects\SourceForge\swerve-sample\src\flex\RESTStreamManager.as:206]
        at 
RESTStreamManager/RESTStreamManager::processMsg()[D:\Data\Projects\SourceForge\swerve-sample\src\flex\RESTStreamManager.as:189]
        at 
RESTStreamManager/RESTStreamManager::consumeBytes()[D:\Data\Projects\SourceForge\swerve-sample\src\flex\RESTStreamManager.as:134]
        at 
RESTStreamManager/RESTStreamManager::progressHandler()[D:\Data\Projects\SourceForge\swerve-sample\src\flex\RESTStreamManager.as:250]





Any ideas?

Thanks,


Travell

_______________________________________________
Red5 mailing list
[email protected]
http://osflash.org/mailman/listinfo/red5_osflash.org

Reply via email to