<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>amf3 &#8211; Alessandro Crugnola &#8211; sephiroth.it</title>
	<atom:link href="https://blog.sephiroth.it/tag/amf3/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.sephiroth.it</link>
	<description>programmer by pure chance</description>
	<lastBuildDate>Mon, 21 Jun 2010 10:27:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://blog.sephiroth.it/wp-content/uploads/2019/03/cropped-sepy-big-32x32.png</url>
	<title>amf3 &#8211; Alessandro Crugnola &#8211; sephiroth.it</title>
	<link>https://blog.sephiroth.it</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>AMFPHP issue referencing ByteArray</title>
		<link>https://blog.sephiroth.it/2008/07/11/amfphp-issue-referencing-bytearray/</link>
					<comments>https://blog.sephiroth.it/2008/07/11/amfphp-issue-referencing-bytearray/#comments</comments>
		
		<dc:creator><![CDATA[Alessandro Crugnola]]></dc:creator>
		<pubDate>Fri, 11 Jul 2008 17:08:49 +0000</pubDate>
				<category><![CDATA[amfphp]]></category>
		<category><![CDATA[amf3]]></category>
		<category><![CDATA[blob]]></category>
		<category><![CDATA[bytearray]]></category>
		<category><![CDATA[encoding]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[netconnection]]></category>
		<category><![CDATA[objectencoding]]></category>
		<category><![CDATA[patch]]></category>
		<guid isPermaLink="false">http://blog.sephiroth.it/?p=258</guid>

					<description><![CDATA[Recently I made some test in AMFPHP sending an retrieving ByteArray to be stored in a mysql blob field. But suddenly I encounter a problem when I was trying to return an array of ByteArrays and I could not find out the reason flash continued to show me this error: The php file which was &#8230; <a href="https://blog.sephiroth.it/2008/07/11/amfphp-issue-referencing-bytearray/" class="more-link">Continue reading <span class="screen-reader-text">AMFPHP issue referencing ByteArray</span></a>]]></description>
										<content:encoded><![CDATA[<p>Recently I made some test in AMFPHP sending an retrieving ByteArray to be stored in a mysql blob field.</p>
<p>But suddenly I encounter a problem when I was trying to return an array of ByteArrays and I could not find out the reason flash continued to show me this error:</p>
<p><a href="https://blog.sephiroth.it/wp-content/uploads/2008/07/error_dialog.png"><img decoding="async" class="alignnone size-medium wp-image-1117" title="error_dialog" src="https://blog.sephiroth.it/wp-content/uploads/2008/07/error_dialog-300x126.png" alt="" width="300" height="126" srcset="https://blog.sephiroth.it/wp-content/uploads/2008/07/error_dialog-300x126.png 300w, https://blog.sephiroth.it/wp-content/uploads/2008/07/error_dialog.png 658w" sizes="(max-width: 300px) 100vw, 300px" /></a></p>
<p>The php file which was generating this error was:<br />
<code lang="php"><br />
class Service<br />
{<br />
public function getArray( )<br />
{<br />
$GLOBALS['amfphp']['encoding'] = 'amf3';<br />
$a = new ByteArray("\x00\x10this is a string");<br />
$b = new ByteArray("\x00\x16this is another string");<br />
$c = $a;<br />
return array( $a, $b, $c );<br />
}<br />
}<br />
</code><br />
While the Actionscript test class was:<br />
<code><br />
package<br />
{<br />
    import flash.display.Sprite;<br />
    import flash.net.NetConnection;<br />
    import flash.net.ObjectEncoding;<br />
    import flash.net.Responder;<br />
    import flash.utils.ByteArray;</p>
<p>    public class test extends Sprite<br />
    {<br />
        private var nc: NetConnection;<br />
        private var rsp: Responder;</p>
<p>        public function test()<br />
        {<br />
            rsp = new Responder( onResult, null );<br />
            nc = new NetConnection();<br />
            nc.objectEncoding = ObjectEncoding.AMF3;<br />
            nc.connect( "http://localhost/amfphp/trunk/gateway.php" );<br />
            nc.call( "test.bytearray.Service.getArray", rsp );<br />
        }</p>
<p>        private function onResult( e: * ): void<br />
        {<br />
            if ( e is Array )<br />
            {<br />
                for each ( var b: ByteArray in( e as Array ) )<br />
                {<br />
                    trace( 'reading bytearray...' );<br />
                    b.position = 0;<br />
                    trace( b.readUTF() );<br />
                }<br />
            }<br />
        }<br />
    }<br />
}</p>
<p></code><br />
After some investigation I found that the error was into the AMFSerializer.php file in the writeAmf3ByteArray method which doesn&#8217;t reference correctly the bytearray objects.</p>
<p>Thus I made a little modification and after that I succeeded to retrieve correctly the bytearray list ( with the 3rd element as reference of the first one ).</p>
<p>Here you can <a title="bytearray.patch" href="https://blog.sephiroth.it/wp-content/uploads/2008/07/bytearray_patch.zip">download the patch file</a>, if you want to test the modification ( at your own risk 🙂 ). The patch has been created using the last svn version of amfphp and you can apply the patch with the following command:<br />
<code>patch -p0 -i bytearray.patch</code></p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.sephiroth.it/2008/07/11/amfphp-issue-referencing-bytearray/feed/</wfw:commentRss>
			<slash:comments>7</slash:comments>
		
		
			</item>
		<item>
		<title>AMFPHP and mbstring</title>
		<link>https://blog.sephiroth.it/2007/10/11/amfphp-and-mbstring/</link>
					<comments>https://blog.sephiroth.it/2007/10/11/amfphp-and-mbstring/#comments</comments>
		
		<dc:creator><![CDATA[Alessandro Crugnola]]></dc:creator>
		<pubDate>Fri, 12 Oct 2007 05:49:02 +0000</pubDate>
				<category><![CDATA[amfphp]]></category>
		<category><![CDATA[amf3]]></category>
		<category><![CDATA[amf3broker]]></category>
		<category><![CDATA[Channel.Ping.Failed]]></category>
		<category><![CDATA[mbstring]]></category>
		<category><![CDATA[php5]]></category>
		<guid isPermaLink="false">http://blog.sephiroth.it/?p=235</guid>

					<description><![CDATA[These days I was working on a flex 2/amfphp project and I discovered a very strange issue accidentally. With PHP 5.2.4 installed both on local and remote server, the local amfphp works and the remote gave errors. Connecting to the service browser I was receiving the error &#8220;Channel.Ping.Failed&#8221; error and investingating a bit more in &#8230; <a href="https://blog.sephiroth.it/2007/10/11/amfphp-and-mbstring/" class="more-link">Continue reading <span class="screen-reader-text">AMFPHP and mbstring</span></a>]]></description>
										<content:encoded><![CDATA[<p>These days I was working on a flex 2/amfphp project and I discovered a very strange issue accidentally.<br />
With PHP 5.2.4 installed both on local and remote server, the local amfphp works and the remote gave errors.</p>
<p>Connecting to the service browser I was receiving the error &#8220;Channel.Ping.Failed&#8221; error and investingating a bit more in the fault message I discovered that the source error was:</p>
<blockquote><p><em> The class {Amf3Broker} could not be found under the class path {/var/htdocs/amfphp/services/amfphp/Amf3Broker.php} </em></p></blockquote>
<p>and the Amf3Broker php class does not exists anywhere in amfphp! But in the Actions.php file on line 78 I found this:<br />
<code lang="php">if(!$handled)<br />
{<br />
$uriclasspath = "amfphp/Amf3Broker.php";<br />
$classpath = $baseClassPath . "amfphp/Amf3Broker.php";<br />
$classname = "Amf3Broker";<br />
$methodname = "handleMessage";<br />
}</code><br />
That&#8217;s the strange thing because the $handled variable should be true &#8217;cause usually the first request sent by flash is a <strong>$messageType = &#8220;flex.messaging.messages.CommandMessage&#8221;</strong>. So I continued in my investigation logging all the messages that php was receiving.<br />
So at the end I discovered that amfphp didn&#8217;t deserialize the amf data correctly! All the packet were corrupted (that&#8217;s why $messageType wasn&#8217;t handled), all the strings were not correctly parsed.<br />
Finally I discovered the reason. It&#8217;s because <a href="http://it2.php.net/mbstring" target="_blank">mbstring</a>.<br />
The only difference between the remote server and the local server is the php.ini setting about mbstring <a href="http://it2.php.net/manual/en/ref.mbstring.php#mbstring.overload" target="_blank">overload</a> and the others mbstring settings.<br />
The remote server has mbstring.func_overload = 2, that means all the strings functions are affected and that&#8217;s why the amfphp methods were returing corrupted data.<br />
In fact I just changed this method into AMFDeserializer.php:<br />
<code lang="php">function readBuffer($len)<br />
{<br />
$data = substr($this->raw_data,$this->current_byte,$len);<br />
$this->current_byte += $len;<br />
return $data;<br />
}</code><br />
into:<br />
<code lang="php">function readBuffer($len)<br />
{<br />
$data = "";<br />
for($i = 0; $i < $len; $i++)
{
$data .= $this->raw_data{$i + $this->current_byte};<br />
}<br />
$this->current_byte += $len;<br />
return $data;<br />
}</code><br />
and the original error disappeared! Obviously I got other errors later, that&#8217;s because there are many other string functions in amfphp.. but at least I found the cause.</p>
<p>In fact, removing the mbstring.func_overload in the php.ini everything worked again!</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.sephiroth.it/2007/10/11/amfphp-and-mbstring/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
		<item>
		<title>AMFPHP 1.9 changes and future plans</title>
		<link>https://blog.sephiroth.it/2006/12/13/amfphp-1-9-changes-and-future-plans/</link>
					<comments>https://blog.sephiroth.it/2006/12/13/amfphp-1-9-changes-and-future-plans/#comments</comments>
		
		<dc:creator><![CDATA[Alessandro Crugnola]]></dc:creator>
		<pubDate>Thu, 14 Dec 2006 00:35:33 +0000</pubDate>
				<category><![CDATA[amfphp]]></category>
		<category><![CDATA[amf3]]></category>
		<category><![CDATA[ArrayCollection]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[Flex Data Services]]></category>
		<category><![CDATA[methodTable]]></category>
		<guid isPermaLink="false">http://blog.sephiroth.it/?p=189</guid>

					<description><![CDATA[<p>amfphp 1.9 now supports AMF3 Flex2 object encoding. Future plans are the integration of Flash data services in amfphp too.</p>
]]></description>
										<content:encoded><![CDATA[<p>Recently <a href="http://5etdemi.com/blog" target="_blank">Patrick</a> released a new testing version of <a href="http://5etdemi.com/uploads/amfphp-1.9.alpha.zip">AMFPHP</a> which supports the Flex2 AMF3 object encoding.</p>
<p>Some changes:</p>
<p>&#8211; <strong>$this-&gt;methodTable</strong> is DEAD. All methods in /services are now considered remotely accessible, unless you set them to protected or private (PHP5) or start the method name with an (_)<br />
&#8211; Returning a <strong>mysql_query</strong> will now return either an Array or an ArrayCollection depending on the setting in gateway.php<br />
&#8211; browser now brings up the brand spanking new Flex 2-based service browser</p>
<p>This is a testing version since it has still a lot of limitations and it has been tested only on PHP5. I see the post today and I haven&#8217;t tested yet&#8230;<br />
You can <a href="http://www.cflex.net/flexcoders.cfm?Message=msg48803.html" target="_blank">read here</a> for a detailed list of changes</p>
<p>Moreover Patrick plans to add to amfphp the Flex Data Services (<a href="http://www.adobe.com/products/flex/dataservices/" target="_blank">read what they are</a>). In this <a href="http://www.5etdemi.com/blog/archives/2006/12/call-to-arms-amfphp-with-flex-data-services-functionality/" target="_blank">post</a> he got a brief explanation about flash player/FDS communication and ask for developers to help him with the developement of FDS in amfphp (you might need a copy of <a href="http://www.xk72.com/charles/" target="_blank">charles</a>).</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.sephiroth.it/2006/12/13/amfphp-1-9-changes-and-future-plans/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
	</channel>
</rss>
