<?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/"
	>

<channel>
	<title>Weasel Project</title>
	<atom:link href="http://blog.weasel-project.com/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.weasel-project.com</link>
	<description>a comet service on steroides</description>
	<pubDate>Mon, 18 May 2009 10:53:48 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Coding Day #4 - flash chunks</title>
		<link>http://blog.weasel-project.com/coding-day/coding-day-4-flash-chunks.html</link>
		<comments>http://blog.weasel-project.com/coding-day/coding-day-4-flash-chunks.html#comments</comments>
		<pubDate>Thu, 14 May 2009 11:43:45 +0000</pubDate>
		<dc:creator>headcrap</dc:creator>
		
		<category><![CDATA[Coding Day]]></category>

		<guid isPermaLink="false">http://92.51.164.164/blog/?p=5</guid>
		<description><![CDATA[
On the last coding day we tested our weasel test rpg demo with two macs and one windows pc. Abrupt the windows pc doesnt load the map or other objects correctly. After debugging the windows client we find out that the javascript get small chunks and not the full package.  So whats going on !? [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://farm4.static.flickr.com/3650/3517299327_f7ed5e4fa7.jpg" alt="Workstations" /></p>
<p>On the last coding day we tested our weasel test rpg demo with two macs and one windows pc. Abrupt the windows pc doesnt load the map or other objects correctly. After debugging the windows client we find out that the javascript get small chunks and not the full package.  So whats going on !? Apparently the windows read buffer is smaller then the mac read buffer.  So the problem occurred. Whats the solution? Right &#8230;. drinking beer</p>
<p>Problem description:</p>
<p style="text-align: left;">1. Server write 5mb string into the stream (map format)</p>
<p style="text-align: left;">2. Flash received only the read buffer size from the os (in this case 1mb) That means flash doesent received one big package but five small chunks (package size / os read buffer)</p>
<p style="text-align: left;">3. Flash calls the javascript function for each chunk</p>
<p style="text-align: left;">4. The javascript gets an chunk from the package and cannot handle it</p>
<p>Solution:</p>
<p>The flash receiver must handle the cunks and build the completed package</p>
<p><span style="font-size: small;">Flash receiver<br />
</span></p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> socketData<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:ProgressEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
    <span style="color: #808080; font-style: italic;">// @TODO handle chunks</span>
    <span style="color: #808080; font-style: italic;">// build the complete package, then call javascript</span>
    <span style="color: #000000; font-weight: bold;">var</span> str:<span style="color: #0066CC;">String</span> = <span style="color: #0066CC;">e</span>.<span style="color: #006600;">currentTarget</span>.<span style="color: #006600;">readUTFBytes</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>.<span style="color: #006600;">currentTarget</span>.<span style="color: #006600;">bytesAvailable</span><span style="color: #66cc66;">&#41;</span>;
    ExternalInterface.<span style="color: #0066CC;">call</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Weasel.dispatch&quot;</span>,str<span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p><span style="font-size: small;">Javascript dispatcher<br />
</span></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">	dispatch <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>json<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #003366; font-weight: bold;">var</span> cmds <span style="color: #339933;">=</span> json.<span style="color: #660066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;|CMD|&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003366; font-weight: bold;">var</span> cmd <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">for</span> each <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> cmd <span style="color: #000066; font-weight: bold;">in</span> cmds<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>cmd <span style="color: #339933;">!=</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #003366; font-weight: bold;">var</span> response <span style="color: #339933;">=</span> JSON.<span style="color: #660066;">parse</span><span style="color: #009900;">&#40;</span>cmd<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
					request<span style="color: #339933;">,</span>
					stack <span style="color: #339933;">=</span> Weasel._getRequestStack<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
				<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>response.<span style="color: #660066;">type</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">&quot;request&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					Weasel._commands<span style="color: #009900;">&#91;</span>response.<span style="color: #660066;">command</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#40;</span>response.<span style="color: #660066;">params</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
					request <span style="color: #339933;">=</span> stack<span style="color: #009900;">&#91;</span>response.<span style="color: #660066;">commandId</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
					request.<span style="color: #660066;">callback</span><span style="color: #009900;">&#40;</span>response.<span style="color: #660066;">params</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	
				<span style="color: #009900;">&#125;</span>	
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span></pre></div></div>

<p><img src="http://farm4.static.flickr.com/3328/3471732924_ded8720ac9.jpg?v=0" alt="Coding Day #4" /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.weasel-project.com/coding-day/coding-day-4-flash-chunks.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>Coding Day #2/3</title>
		<link>http://blog.weasel-project.com/coding-day/coding-day-23.html</link>
		<comments>http://blog.weasel-project.com/coding-day/coding-day-23.html#comments</comments>
		<pubDate>Mon, 27 Apr 2009 07:55:49 +0000</pubDate>
		<dc:creator>hackfrag</dc:creator>
		
		<category><![CDATA[Coding Day]]></category>

		<guid isPermaLink="false">http://blog.weasel-project.com/?p=33</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p><img class="aligncenter" title="Coding Day #2 / #3" src="http://farm4.static.flickr.com/3554/3471554320_7cc742ae62.jpg" alt="" width="500" height="333" /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.weasel-project.com/coding-day/coding-day-23.html/feed</wfw:commentRss>
		</item>
	</channel>
</rss>

