<?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>robskelly.com &#187; BlazeDS</title>
	<atom:link href="http://blog.robskelly.com/category/blazeds/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.robskelly.com</link>
	<description>Flash, Flex, Geography and GIS</description>
	<lastBuildDate>Fri, 19 Mar 2010 06:10:24 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>AppendToGatewayUrl</title>
		<link>http://blog.robskelly.com/2009/06/appendtogatewayurl/</link>
		<comments>http://blog.robskelly.com/2009/06/appendtogatewayurl/#comments</comments>
		<pubDate>Mon, 22 Jun 2009 23:08:09 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[BlazeDS]]></category>
		<category><![CDATA[FLEX]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://blog.robskelly.com/?p=93</guid>
		<description><![CDATA[If you&#8217;re using BlazeDS and seeing an error involving a callback called &#8220;AppendToGatewayUrl&#8221; this might help.
AppendToGatewayUrl modifies the gateway of a NetConnection object with the session id (in this case &#8220;jsessionid&#8221;) of the current session. If you reconnect with this value appended to the gateway URL, your session can be identified, even on clients that [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re using BlazeDS and seeing an error involving a callback called &#8220;AppendToGatewayUrl&#8221; this might help.</p>
<p>AppendToGatewayUrl modifies the gateway of a NetConnection object with the session id (in this case &#8220;jsessionid&#8221;) of the current session. If you reconnect with this value appended to the gateway URL, your session can be identified, even on clients that do not use cookies.</p>
<p>There are two ways to handle this:</p>
<ul style="list-style:none;">
<li>set NetConnection.client to an object that implements the AppendToGatewayUrl function, or;</li>
<li>subclass NetConnection to implement it (since NetConnection.client points to the NetConnection instance by default, you can not reassign the client field if you want this method to work).</li>
</ul>
<p>There&#8217;s one caveat to both approaches, though. It has been my experience that if you call NetConnection.connect while you are receiving a response to bundled remote methods, the data may be lost or a &#8220;Client.Data.UnderFlow&#8221; error thrown. This occurs because AppendToGatewayUrl gets called after the first result, and the immediate call to NetConnection.connect aborts the rest of the transfer.</p>
<p>Here&#8217;s a sample implementation of option A:</p>
<div class="codesnip-container" >
<div class="actionscript codesnip" style="font-family:monospace;"><span class="kw3">public</span> <span class="kw2">class</span> Sample<span class="br0">&#123;</span></p>
<p>&nbsp; <span class="kw3">private</span> <span class="kw2">var</span> conn : <span class="kw3">NetConnection</span>;</p>
<p>&nbsp; <span class="kw3">public</span> <span class="kw2">function</span> Sample<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span><br />
&nbsp; &nbsp; conn = <span class="kw2">new</span> <span class="kw3">NetConnection</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; conn .<span class="me1">client</span> = <span class="kw3">this</span>;<br />
&nbsp; &nbsp; conn .<span class="kw3">connect</span><span class="br0">&#40;</span><span class="st0">&#8216;http://localhost/gateway&#8217;</span><span class="br0">&#41;</span>;<br />
&nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; <span class="kw3">public</span> <span class="kw2">function</span> AppendToGatewayUrl<span class="br0">&#40;</span>extra:<span class="kw3">String</span><span class="br0">&#41;</span>:<span class="kw3">void</span><span class="br0">&#123;</span><br />
&nbsp; &nbsp; conn .<span class="kw3">connect</span><span class="br0">&#40;</span>conn.<span class="me1">uri</span> + extra<span class="br0">&#41;</span>;<br />
&nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; <span class="kw3">public</span> <span class="kw2">function</span> <span class="kw3">load</span><span class="br0">&#40;</span><span class="br0">&#41;</span>:<span class="kw3">void</span><span class="br0">&#123;</span><br />
&nbsp; &nbsp; conn .<span class="kw3">call</span><span class="br0">&#40;</span><span class="st0">&#8217;service.load&#8217;</span>,<span class="kw2">new</span> Responder<span class="br0">&#40;</span>loadResult,<span class="kw3">error</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
&nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; <span class="kw3">private</span> <span class="kw2">function</span> loadResult<span class="br0">&#40;</span>value:<span class="sy0">*</span><span class="br0">&#41;</span>:<span class="kw3">void</span><span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw3">trace</span><span class="br0">&#40;</span><span class="st0">&#8216;value&#8217;</span>,value<span class="br0">&#41;</span>;<br />
&nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; <span class="kw3">private</span> <span class="kw2">function</span> <span class="kw3">error</span><span class="br0">&#40;</span>err:<span class="sy0">*</span><span class="br0">&#41;</span>:<span class="kw3">void</span><span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw3">trace</span><span class="br0">&#40;</span><span class="st0">&#8216;error&#8217;</span>,err.<span class="kw3">message</span><span class="br0">&#41;</span>;<br />
&nbsp; <span class="br0">&#125;</span></p>
<p><span class="br0">&#125;</span></div>
</div>
<p>To get around the problem with bundled calls, you could save the session id in a field and reconnect before the next call.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.robskelly.com/2009/06/appendtogatewayurl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
