AMFPHP: Serializing Flash Objects over HTTP without the gateway

nelliesienna

New Member
Flash + AMFPHP is a great combination. But there are cases, when Flash Remoting with NetConnection isn't the right tool, for various reasons. Rob had a great post on this some time ago: http://www.roboncode.com/articles/144He also has a nice example on how to deliver AMF to a http request, without the POST and AMF-request package to call the function that NetConnection sends, using Zend_AMF.\[code\]// Include the Zend Loaderinclude_once 'Zend/Loader.php';// Tell the Zend Loader to autoload any classes we need// from the Zend Framework AMF packageZend_Loader::registerAutoload();// Create a simple data structure$data = http://stackoverflow.com/questions/2081402/array('message' => 'Hello, world!');// Create an instance of an AMF Output Stream$out = new Zend_Amf_Parse_OutputStream();// We will serialize our content into AMF3 for this example// You could alternatively serialize it as AMF0 for legacy// Flash applications.$s = new Zend_Amf_Parse_Amf3_Serializer($out);$s->writeObject($data);// Return the content (we have found the newline is needed// in order to process the data correctly on the client side)echo "\n" . $out->getStream();\[/code\]I really like this approach and would be very hapy to replicate it with AMFPHP. Why AMFPHP, you ask? The 'newest' version uses amf-ext, a C PHP extension, to serialize and deserialize the data. It is much faster than the php way ZendAMF is still using.Of course I already played around with AMFPHP and tried to build the necessary objects and use the Serializer class. I even got a valid AMF string, but the real data was always wrapped by a 'method package' that told the receiver this was a answer to 'Service.method' call.So is there a way to serialize Flash Objects directly, without the gateway and method wrapper, in AMFPHP?Thanks.
 
Back
Top