<?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>Florent Clairambault &#187; Javascript</title>
	<atom:link href="http://florent.clairambault.fr/tag/javascript/feed" rel="self" type="application/rss+xml" />
	<link>http://florent.clairambault.fr</link>
	<description></description>
	<lastBuildDate>Sat, 04 Feb 2012 19:56:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4-alpha-19719</generator>
		<item>
		<title>Ajax Push Engine 1.0 released</title>
		<link>http://florent.clairambault.fr/ajax-push-engine-1-0-released?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=ajax-push-engine-1-0-released</link>
		<comments>http://florent.clairambault.fr/ajax-push-engine-1-0-released#comments</comments>
		<pubDate>Tue, 08 Dec 2009 06:45:18 +0000</pubDate>
		<dc:creator>Florent Clairambault</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[APE]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[push]]></category>
		<category><![CDATA[SpiderMonkey]]></category>

		<guid isPermaLink="false">http://florent.clairambault.fr/?p=2129</guid>
		<description><![CDATA[I&#8217;m quite unlucky because I&#8217;ve downloaded the APE BETA5 just before they (I mean Anthony Catel) released the 1.0. The quite interesting part is that it fixes all the bugs I&#8217;ve talked about sooner. So we could say my last post won&#8217;t be very useful to anyone. Still, if you want to compile APE on [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m quite unlucky because I&#8217;ve downloaded the APE BETA5 just before they (I mean Anthony Catel) released the 1.0. The quite interesting part is that it fixes all the bugs I&#8217;ve talked about sooner. So we could say my last post won&#8217;t be very useful to anyone.</p>
<p>Still, if you want to compile APE on CentOS x64, you have have to edit the modules/Makefile file and add the &#8220;-L/usr/lib64/mysql&#8221; command arg. It will give you something like that :</p>

<div class="wp_codebox"><table><tr id="p21292"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p2129code2"><pre class="sh" style="font-family:monospace;">ifeq ($(HAS_MYSQL), yes)
        MYSQL_FLAGS = -L./deps/mysac/ -I./deps/mysac/ -lmysac -L/usr/lib64/mysql -lmysqlclient_r
endif</pre></td></tr></table></div>

<p>They also added some <a href="http://www.ape-project.org/en/demos/">new great demos</a> but they are not included in the 1.0 sources. I&#8217;ve been closely following their websites for the last two days and they did an awesome job in a very short time. And I guess a lof of people are taking interest in this project because you can see a lot of monkeys on the <a href="http://www.ape-project.org/en/home.html">APE home page</a>.</p>
<p>As soon as possible, I will make some little test with the very interesting <a href="http://github.com/APE-Project/APE_Server/tree/master/scripts/">javascript server-side code</a> based on <a href="http://www.mozilla.org/js/spidermonkey/">SpiderMonkey</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://florent.clairambault.fr/ajax-push-engine-1-0-released/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Ajax Push Engine 1.0 Beta 5</title>
		<link>http://florent.clairambault.fr/ajax-push-engine-1-0beta5?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=ajax-push-engine-1-0beta5</link>
		<comments>http://florent.clairambault.fr/ajax-push-engine-1-0beta5#comments</comments>
		<pubDate>Sun, 06 Dec 2009 21:00:47 +0000</pubDate>
		<dc:creator>Florent Clairambault</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[APE]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[push]]></category>

		<guid isPermaLink="false">http://florent.clairambault.fr/?p=2103</guid>
		<description><![CDATA[I talked quickly about APE in a recent post. I recently downloaded a new version of their program and I&#8217;ve installed it successfully and it works much better. Since the first released verison, it has become quite easy, you just have to launch &#8220;./build.sh&#8221;. I had some problems with the linker on my CentOS system [...]]]></description>
			<content:encoded><![CDATA[<p>I talked quickly about <a href="http://www.ape-project.org/">APE</a> in <a href="http://florent.clairambault.fr/push-comet-or-pull">a recent post</a>. I recently downloaded a new version of their program and<br />
I&#8217;ve installed it successfully and it works much better. Since the first released verison, it has become quite easy, you just have to launch &#8220;./build.sh&#8221;. I had some problems with the linker on my CentOS system and the mysql libraries. But I solved it by added &#8220;-L/var/lib64/mysql&#8221; to some line of the Makefile.</p>
<p><strong>How to make the demos work</strong><br />
They are some tiny bugs that took me quite some time to bypass :</p>
<ul>
<li>To use the <a href="http://ape.webingenia.com/Demos/Controller/demo.html">controller demo</a>, <a name="fix_controller">you need to</a> put the modules/conf/inlinepush.conf file into bin. I guess this will be fixed someday soon but still, that&#8217;s how it works right now.</li>
<li>To use the <a href="http://ape.webingenia.com/Demos/Move/demo.html">move demo</a>, <a name="fix_move">you need to</a> change the scripts/main.ape.js file and add this line :

<div class="wp_codebox"><table><tr id="p210310"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p2103code10"><pre class="javascript" style="font-family:monospace;">include<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;examples/move.js&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

</li>
<li>To use the <a href="http://ape.webingenia.com/Demos/Controller/demo.html">TCPSocket demo</a>, you need to copy the modules/conf/proxy.conf file into bin.</li>
</ul>
<p>Note : Each time you modify a script file (within the &#8220;scripts&#8221; directoy of APE), you have to restart the server.</p>
<p><strong>The very interesting javascript backend</strong><br />
This project is very interesting because everything in the backend is handled by some little javascript files, the move example file is this one :</p>

<div class="wp_codebox"><table><tr id="p210311"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
</pre></td><td class="code" id="p2103code11"><pre class="javascript" style="font-family:monospace;">Ape.<span style="color: #660066;">registerCmd</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'setpos'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>params<span style="color: #339933;">,</span> infos<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><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>$defined<span style="color: #009900;">&#40;</span>params.<span style="color: #660066;">x</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #339933;">!</span>$defined<span style="color: #009900;">&#40;</span>params.<span style="color: #660066;">y</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>isFinite<span style="color: #009900;">&#40;</span>params.<span style="color: #660066;">x</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #339933;">!</span>isFinite<span style="color: #009900;">&#40;</span>params.<span style="color: #660066;">y</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
&nbsp;
        infos.<span style="color: #660066;">user</span>.<span style="color: #660066;">setProperty</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'x'</span><span style="color: #339933;">,</span> params.<span style="color: #660066;">x</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        infos.<span style="color: #660066;">user</span>.<span style="color: #660066;">setProperty</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'y'</span><span style="color: #339933;">,</span> params.<span style="color: #660066;">y</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #006600; font-style: italic;">// We get the channel</span>
        <span style="color: #003366; font-weight: bold;">var</span> chan <span style="color: #339933;">=</span> Ape.<span style="color: #660066;">getChannelByPubid</span><span style="color: #009900;">&#40;</span>params.<span style="color: #660066;">pipe</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #006600; font-style: italic;">// And send the position data of the calling user on it</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>chan<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                chan.<span style="color: #660066;">pipe</span>.<span style="color: #660066;">sendRaw</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'positions'</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span><span style="color: #3366CC;">'x'</span><span style="color: #339933;">:</span> params.<span style="color: #660066;">x</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'y'</span><span style="color: #339933;">:</span> params.<span style="color: #660066;">y</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span><span style="color: #3366CC;">'from'</span><span style="color: #339933;">:</span> infos.<span style="color: #660066;">user</span>.<span style="color: #660066;">pipe</span><span style="color: #009900;">&#125;</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>
                <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'109'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'UNKNOWN_PIPE'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>This is what allows the client to send this kind of request :</p>

<div class="wp_codebox"><table><tr id="p210312"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p2103code12"><pre class="json" style="font-family:monospace;">[{&quot;cmd&quot;:&quot;SETPOS&quot;,&quot;chl&quot;:10,&quot;params&quot;:{&quot;x&quot;:282,&quot;y&quot;:38,&quot;pipe&quot;:&quot;3dcaa701e8ee3394d65d5f71cd18e428&quot;},&quot;sessid&quot;:&quot;b897476d835d12c150fb9fc337c7c93d&quot;}]</pre></td></tr></table></div>

<p>If you don&#8217;t add the include line, the answer will be something like that :</p>

<div class="wp_codebox"><table><tr id="p210313"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p2103code13"><pre class="json" style="font-family:monospace;">[{&quot;time&quot;:&quot;1260123358&quot;,&quot;raw&quot;:&quot;ERR&quot;,&quot;data&quot;:{&quot;chl&quot;:10,&quot;code&quot;:&quot;003&quot;,&quot;value&quot;:&quot;BAD_CMD&quot;}}]</pre></td></tr></table></div>

<p>The &#8220;BAD_CMD&#8221; reply means that this commands hasn&#8217;t be registered by the Ape.registerCmd method. If you come here because that happened to you, just <a href="#fix_move">fix it</a>.</p>
<p>For the Controller demo, this is exactly the same. The file is :</p>

<div class="wp_codebox"><table><tr id="p210314"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
</pre></td><td class="code" id="p2103code14"><pre class="javascript" style="font-family:monospace;">Ape.<span style="color: #660066;">registerCmd</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;inlinepush&quot;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>params<span style="color: #339933;">,</span> infos<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #006600; font-style: italic;">// We check the password (&quot;password&quot; parameter of the &quot;inlinepush.conf&quot; file)</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>params.<span style="color: #660066;">password</span> <span style="color: #339933;">==</span> Ape.<span style="color: #660066;">config</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;inlinepush.conf&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;password&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #006600; font-style: italic;">// If every request parameters have been correctly defined</span>
                <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>$defined<span style="color: #009900;">&#40;</span>params.<span style="color: #660066;">channel</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> $defined<span style="color: #009900;">&#40;</span>params.<span style="color: #660066;">data</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> $defined<span style="color: #009900;">&#40;</span>params.<span style="color: #660066;">raw</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                        <span style="color: #006600; font-style: italic;">// We get the channel</span>
                        <span style="color: #003366; font-weight: bold;">var</span> chan <span style="color: #339933;">=</span> Ape.<span style="color: #660066;">getChannelByName</span><span style="color: #009900;">&#40;</span>params.<span style="color: #660066;">channel</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>$defined<span style="color: #009900;">&#40;</span>chan<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">&quot;401&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;UNKNOWN_CHANNEL&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
                        <span style="color: #006600; font-style: italic;">// We send the data (as received) back to the channel</span>
                        chan.<span style="color: #660066;">pipe</span>.<span style="color: #660066;">sendRaw</span><span style="color: #009900;">&#40;</span>params.<span style="color: #660066;">raw</span><span style="color: #339933;">,</span> params.<span style="color: #660066;">data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
                        <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #009900;">&#123;</span><span style="color: #3366CC;">&quot;name&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;pushed&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;data&quot;</span><span style="color: #339933;">:</span><span style="color: #009900;">&#123;</span><span style="color: #3366CC;">&quot;value&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;ok&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#125;</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>
                        <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">&quot;400&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;BAD_PASSWORD&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span></pre></td></tr></table></div>

<p>If you get the the BAD_PASSWORD error response and you&#8217;re not sure why, you can change the BAD_PASSWORD line by :</p>

<div class="wp_codebox"><table><tr id="p210315"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p2103code15"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">return</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">&quot;400&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;BAD_PASSWORD, the right one is :&quot;</span><span style="color: #339933;">+</span>Ape.<span style="color: #660066;">config</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;inlinepush.conf&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;password&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>If you get &#8220;BAD_PASSWORD, the right one is :&#8221;. There&#8217;s a good chance you didn&#8217;t <a href="#fix_controller">move the inlinepush.conf into the bin directory</a>.</p>
<p><strong>Sample communications</strong><br />
Here is a sample chat communication</p>

<div class="wp_codebox"><table><tr id="p210316"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
</pre></td><td class="code" id="p2103code16"><pre class="txt" style="font-family:monospace;">Echange CHAT :
--&gt; [{&quot;cmd&quot;:&quot;script&quot;,&quot;params&quot;:{&quot;domain&quot;:&quot;ape.webingenia.com&quot;,&quot;scripts&quot;:[&quot;http://ape.webingenia.com/Source/mootools-core.js&quot;,&quot;http://ape.webingenia.com/Source/Core/APE.js&quot;,&quot;http://ape.webingenia.com/Source/Core/Events.js&quot;,&quot;http://ape.webingenia.com/Source/Core/Core.js&quot;,&quot;http://ape.webingenia.com/Source/Pipe/Pipe.js&quot;,&quot;http://ape.webingenia.com/Source/Pipe/PipeProxy.js&quot;,&quot;http://ape.webingenia.com/Source/Pipe/PipeMulti.js&quot;,&quot;http://ape.webingenia.com/Source/Pipe/PipeSingle.js&quot;,&quot;http://ape.webingenia.com/Source/Request/Request.js&quot;,&quot;http://ape.webingenia.com/Source/Request/Request.Stack.js&quot;,&quot;http://ape.webingenia.com/Source/Request/Request.CycledStack.js&quot;,&quot;http://ape.webingenia.com/Source/Transport/Transport.longPolling.js&quot;,&quot;http://ape.webingenia.com/Source/Transport/Transport.SSE.js&quot;,&quot;http://ape.webingenia.com/Source/Transport/Transport.XHRStreaming.js&quot;,&quot;http://ape.webingenia.com/Source/Transport/Transport.JSONP.js&quot;,&quot;http://ape.webingenia.com/Source/Core/Utility.js&quot;,&quot;http://ape.webingenia.com/Source/Core/JSON.js&quot;,&quot;http://ape.webingenia.com/Source/Core/Session.js&quot;]}}]
&lt;-- (useless html response)
&nbsp;
// We  try some &quot;CONNECT&quot; and then &quot;JOIN&quot; commands with the name &quot;superfc&quot;
--&gt; [{&quot;cmd&quot;:&quot;CONNECT&quot;,&quot;chl&quot;:1,&quot;params&quot;:{&quot;name&quot;:&quot;superfc&quot;}},{&quot;cmd&quot;:&quot;JOIN&quot;,&quot;chl&quot;:2,&quot;params&quot;:{&quot;channels&quot;:&quot;test&quot;}}]
// Error, the nick name is already use
&lt;-- [{&quot;time&quot;:&quot;1260119123&quot;,&quot;raw&quot;:&quot;ERR&quot;,&quot;data&quot;:{&quot;code&quot;:&quot;005&quot;,&quot;value&quot;:&quot;NICK_USED&quot;}}]
&nbsp;
// We  try some &quot;CONNECT&quot; and then &quot;JOIN&quot; commands with the name &quot;Florent&quot;
--&gt; [{&quot;cmd&quot;:&quot;CONNECT&quot;,&quot;chl&quot;:5,&quot;params&quot;:{&quot;name&quot;:&quot;Hello&quot;}},{&quot;cmd&quot;:&quot;JOIN&quot;,&quot;chl&quot;:6,&quot;params&quot;:{&quot;channels&quot;:&quot;test&quot;}}]
// This works !
&lt;-- [{&quot;time&quot;:&quot;1260119134&quot;,&quot;raw&quot;:&quot;LOGIN&quot;,&quot;data&quot;:{&quot;sessid&quot;:&quot;36a60d006d50882d0d2cd6bcfda90cb9&quot;}},
{&quot;time&quot;:&quot;1260119134&quot;,&quot;raw&quot;:&quot;IDENT&quot;,&quot;data&quot;:{&quot;user&quot;:{&quot;casttype&quot;:&quot;uni&quot;,&quot;pubid&quot;:&quot;8b5fec5af11df915d9806a3be4b46c35&quot;,&quot;properties&quot;:{&quot;name&quot;:&quot;Hello&quot;}}}},
{&quot;time&quot;:&quot;1260119134&quot;,&quot;raw&quot;:&quot;CHANNEL&quot;,&quot;data&quot;:{&quot;users&quot;:[{&quot;casttype&quot;:&quot;uni&quot;,&quot;pubid&quot;:&quot;8b5fec5af11df915d9806a3be4b46c35&quot;,&quot;properties&quot;:{&quot;name&quot;:&quot;Hello&quot;},&quot;level&quot;:1},{&quot;casttype&quot;:&quot;uni&quot;,&quot;pubid&quot;:&quot;cc03a08f304a75cc133827c6c4b561c8&quot;,&quot;properties&quot;:{&quot;name&quot;:&quot;superfc&quot;},&quot;level&quot;:1},{&quot;casttype&quot;:&quot;uni&quot;,&quot;pubid&quot;:&quot;541e78a0fbfbc08457c800aacccd212d&quot;,&quot;properties&quot;:{&quot;name&quot;:&quot;Florent&quot;},&quot;level&quot;:1}],&quot;pipe&quot;:{&quot;casttype&quot;:&quot;multi&quot;,&quot;pubid&quot;:&quot;2b27244bdb42c193d5158e818ec577d0&quot;,&quot;properties&quot;:{&quot;name&quot;:&quot;test&quot;}}}}]
&nbsp;
// We send 
--&gt; [{&quot;cmd&quot;:&quot;SESSION&quot;,&quot;chl&quot;:7,&quot;params&quot;:{&quot;action&quot;:&quot;set&quot;,&quot;values&quot;:{&quot;currentPipe&quot;:&quot;2b27244bdb42c193d5158e818ec577d0&quot;}},&quot;sessid&quot;:&quot;36a60d006d50882d0d2cd6bcfda90cb9&quot;}]
&lt;-- [{&quot;time&quot;:&quot;1260119136&quot;,&quot;raw&quot;:&quot;LEFT&quot;,&quot;data&quot;:{&quot;user&quot;:{&quot;casttype&quot;:&quot;uni&quot;,&quot;pubid&quot;:&quot;cc03a08f304a75cc133827c6c4b561c8&quot;,&quot;properties&quot;:{&quot;name&quot;:&quot;superfc&quot;}},&quot;pipe&quot;:{&quot;casttype&quot;:&quot;multi&quot;,&quot;pubid&quot;:&quot;2b27244bdb42c193d5158e818ec577d0&quot;,&quot;properties&quot;:{&quot;name&quot;:&quot;test&quot;}}}}]
&nbsp;
// These next requests are long polls with nothing
--&gt; [{&quot;cmd&quot;:&quot;CHECK&quot;,&quot;chl&quot;:9,&quot;sessid&quot;:&quot;36a60d006d50882d0d2cd6bcfda90cb9&quot;}]
&nbsp;
// Nothing new
&lt;-- [{&quot;time&quot;:&quot;1260119186&quot;,&quot;raw&quot;:&quot;CLOSE&quot;,&quot;data&quot;:{&quot;value&quot;:&quot;null&quot;}}]
&nbsp;
--&gt; [{&quot;cmd&quot;:&quot;CHECK&quot;,&quot;chl&quot;:10,&quot;sessid&quot;:&quot;36a60d006d50882d0d2cd6bcfda90cb9&quot;}]
&lt;-- [{&quot;time&quot;:&quot;1260119211&quot;,&quot;raw&quot;:&quot;CLOSE&quot;,&quot;data&quot;:{&quot;value&quot;:&quot;null&quot;}}]
&nbsp;
--&gt; [{&quot;cmd&quot;:&quot;CHECK&quot;,&quot;chl&quot;:11,&quot;sessid&quot;:&quot;36a60d006d50882d0d2cd6bcfda90cb9&quot;}]
&lt;-- [{&quot;time&quot;:&quot;1260119239&quot;,&quot;raw&quot;:&quot;CLOSE&quot;,&quot;data&quot;:{&quot;value&quot;:&quot;null&quot;}}]
&nbsp;
// We send some text (&quot;hello&quot;)
--&gt; [{&quot;cmd&quot;:&quot;SEND&quot;,&quot;chl&quot;:19,&quot;params&quot;:{&quot;msg&quot;:&quot;Hello hello&quot;,&quot;pipe&quot;:&quot;2b27244bdb42c193d5158e818ec577d0&quot;},&quot;sessid&quot;:&quot;36a60d006d50882d0d2cd6bcfda90cb9&quot;}]
// And we receive it (&quot;hello&quot;)
&lt;-- [{&quot;time&quot;:&quot;1260119399&quot;,&quot;raw&quot;:&quot;DATA&quot;,&quot;data&quot;:{&quot;msg&quot;:&quot;hello&quot;,&quot;from&quot;:{&quot;casttype&quot;:&quot;uni&quot;,&quot;pubid&quot;:&quot;541e78a0fbfbc08457c800aacccd212d&quot;,&quot;properties&quot;:{&quot;name&quot;:&quot;Florent&quot;}},&quot;pipe&quot;:{&quot;casttype&quot;:&quot;multi&quot;,&quot;pubid&quot;:&quot;2b27244bdb42c193d5158e818ec577d0&quot;,&quot;properties&quot;:{&quot;name&quot;:&quot;test&quot;}}}}]</pre></td></tr></table></div>

<p>If you don&#8217;t understand what is long polling, please look at <a href="http://florent.clairambault.fr/push-comet-or-pull#long_pollmy">previous post on the subject</a>.</p>
<p>Please not that that the &#8220;CLOSE&#8221; RAW isn&#8217;t some sort of &#8220;session closed&#8221; message. I&#8217;m not sure this it&#8217;s what the developer planned but right now it only means that there&#8217;s nothing to receive. So if you get that, don&#8217;t panic. Everything is working fine.</p>
<p><strong>If you need any help&#8230;</strong><br />
Please, don&#8217;t hesitate add some question in the comments, I&#8217;ll be happy to help you.</p>
]]></content:encoded>
			<wfw:commentRss>http://florent.clairambault.fr/ajax-push-engine-1-0beta5/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Lighttpd + Mono ASP.Net : The right configuration</title>
		<link>http://florent.clairambault.fr/lighttpd-mono-asp-net-the-right-configuration?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=lighttpd-mono-asp-net-the-right-configuration</link>
		<comments>http://florent.clairambault.fr/lighttpd-mono-asp-net-the-right-configuration#comments</comments>
		<pubDate>Mon, 18 May 2009 18:34:55 +0000</pubDate>
		<dc:creator>Florent Clairambault</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[C# .Net]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[lighttpd]]></category>
		<category><![CDATA[Mono]]></category>

		<guid isPermaLink="false">http://florent.clairambault.fr/?p=799</guid>
		<description><![CDATA[As I already told before, I love the Mono project. It enables to run the powerful Microsoft .Net Framework on UNIX/Linux/BSD systems. I recently wanted to test a very cool feature of ASP.Net on a mono server. So I did a little 1 apt-get install lighttpd mono-fastcgi-server2 -y The feature I wanted to try was [...]]]></description>
			<content:encoded><![CDATA[<p>As I already told before, I love the <a href="http://www.mono-project.com/">Mono project</a>. It enables to run the powerful Microsoft .Net Framework on UNIX/Linux/BSD systems.</p>
<p>I recently wanted to test a very cool feature of ASP.Net on a mono server. So I did a little</p>

<div class="wp_codebox"><table><tr id="p79922"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p799code22"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> lighttpd mono-fastcgi-server2 <span style="color: #660033;">-y</span></pre></td></tr></table></div>

<p>The feature I wanted to try was a web scripting method ( with the &#8220;[WebMethod]&#8221; attribute) exporting some JSON directly from your method return value.</p>
<p>Here is the web scripting method declaration :</p>

<div class="wp_codebox"><table><tr id="p79923"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code" id="p799code23"><pre class="csharp" style="font-family:monospace;">&nbsp;
<span style="color: #008000;">&#91;</span>ScriptService<span style="color: #008000;">&#93;</span>
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">partial</span> <span style="color: #6666cc; font-weight: bold;">class</span> _Default<span style="color: #008000;">:</span>Page <span style="color: #008000;">&#123;</span>
&nbsp;
	<span style="color: #008000;">&#91;</span>WebMethod<span style="color: #008000;">&#93;</span>
	<span style="color: #008000;">&#91;</span>ScriptMethod<span style="color: #008000;">&#40;</span> ResponseFormat <span style="color: #008000;">=</span> ResponseFormat<span style="color: #008000;">.</span><span style="color: #0000FF;">Json</span>, UseHttpGet <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">false</span> <span style="color: #008000;">&#41;</span><span style="color: #008000;">&#93;</span>
	<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">String</span> TestMethod<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
		<span style="color: #0600FF; font-weight: bold;">return</span> DateTime<span style="color: #008000;">.</span><span style="color: #0000FF;">Now</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ToString</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
	<span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>And here is the javascript / JQuery code that gets the data :</p>

<div class="wp_codebox"><table><tr id="p79924"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
</pre></td><td class="code" id="p799code24"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;toto&quot;</span><span style="color: #339933;">&gt;&lt;/</span>div<span style="color: #339933;">&gt;</span>
&nbsp;
<span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
    <span style="color: #003366; font-weight: bold;">function</span> doIt<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        $<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            $.<span style="color: #660066;">ajax</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
                type<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;POST&quot;</span><span style="color: #339933;">,</span>
                url<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;/Default.aspx/TestMethod&quot;</span><span style="color: #339933;">,</span>
                contentType<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;application/json; charset=utf-8&quot;</span><span style="color: #339933;">,</span>
                data<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;{}&quot;</span><span style="color: #339933;">,</span>
                dataType<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;json&quot;</span><span style="color: #339933;">,</span>
                success<span style="color: #339933;">:</span> AjaxSucceeded<span style="color: #339933;">,</span>
                error<span style="color: #339933;">:</span> AjaxFailed
            <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003366; font-weight: bold;">function</span> AjaxSucceeded<span style="color: #009900;">&#40;</span>result<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;toto&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">=</span> result.<span style="color: #660066;">d</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #003366; font-weight: bold;">function</span> AjaxFailed<span style="color: #009900;">&#40;</span>result<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
           document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;toto&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;Error : &quot;</span><span style="color: #339933;">+</span>result.<span style="color: #000066;">status</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">' '</span> <span style="color: #339933;">+</span> result.<span style="color: #660066;">statusText</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        setTimeout<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;doIt()&quot;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">1000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    doIt<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>In my /etc/lighttpd/conf-enabled/10-fastcgi.conf file, I had this :</p>

<div class="wp_codebox"><table><tr id="p79925"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
</pre></td><td class="code" id="p799code25"><pre class="txt" style="font-family:monospace;">server.modules   += ( &quot;mod_fastcgi&quot; )
fastcgi.server    = (
        &quot;&quot; =&gt; ((
                &quot;socket&quot; =&gt; mono_shared_dir + &quot;fastcgi-mono-server&quot;,
                &quot;bin-path&quot; =&gt; mono_fastcgi_server,
                &quot;bin-environment&quot; =&gt; (
                        &quot;PATH&quot; =&gt; &quot;/bin:/usr/bin:&quot; + mono_dir + &quot;bin&quot;,
                        &quot;LD_LIBRARY_PATH&quot; =&gt; mono_dir + &quot;lib:&quot;,
                        &quot;MONO_SHARED_DIR&quot; =&gt; mono_shared_dir,
                        &quot;MONO_FCGI_LOGLEVELS&quot; =&gt; &quot;Standard&quot;,
                        &quot;MONO_FCGI_LOGFILE&quot; =&gt; &quot;/var/log/lighttpd/mono.log&quot;,
                        &quot;MONO_FCGI_ROOT&quot; =&gt; mono_fcgi_root,
                        &quot;MONO_FCGI_APPLICATIONS&quot; =&gt; mono_fcgi_applications
                ),
                &quot;max-procs&quot; =&gt; 1,
                &quot;check-local&quot; =&gt; &quot;disable&quot;
        ))
)</pre></td></tr></table></div>

<p>Everytime I launched a call from javascript, I got (with JS) I got a &#8220;405 Method not allowed&#8221;. Well, that was pretty disturbing. Mostly because <a href="http://www.google.com/search?q=405+method+not+allowed+mono+WebMethod">a google search on this</a> didn&#8217;t give me anything.<br />
My first thought was that mono didn&#8217;t react the same way the .Net framework does. But this isn&#8217;t it. It came from my crappy lighttpd config file. It didn&#8217;t search for the Default.aspx file but for the Default.aspx/TesMethod.<br />
What you need to do is set :</p>

<div class="wp_codebox"><table><tr id="p79926"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
</pre></td><td class="code" id="p799code26"><pre class="txt" style="font-family:monospace;">fastcgi.server    = (
        &quot;.aspx&quot; =&gt; ((
            # Everything you have in your file (like my file above)
        )
&nbsp;
fastcgi.map-extensions = (
        &quot;.asmx&quot;   =&gt; &quot;.aspx&quot;,
        &quot;.ashx&quot;   =&gt; &quot;.aspx&quot;,
        &quot;.asax&quot;   =&gt; &quot;.aspx&quot;,
        &quot;.ascx&quot;   =&gt; &quot;.aspx&quot;,
        &quot;.soap&quot;   =&gt; &quot;.aspx&quot;,
        &quot;.rem&quot;    =&gt; &quot;.aspx&quot;,
        &quot;.axd&quot;    =&gt; &quot;.aspx&quot;,
        &quot;.cs&quot;     =&gt; &quot;.aspx&quot;,
        &quot;.config&quot; =&gt; &quot;.aspx&quot;,
        &quot;.dll&quot;    =&gt; &quot;.aspx&quot;
)</pre></td></tr></table></div>

<p>And that will even improve your performances because any other file will be handled directly by lighttpd.</p>
<p>One quick note : There&#8217;s something weird with VS2008 WebDev.WebServer.Exe, the WebMethod request takes at least 1.0s to complete. On the same host with XSP, it&#8217;s around 15 ms. And on the Celeron 2.6Ghz linux server with lighttpd it&#8217;s around 12 ms. And on a IIS 7 server (bundled with Windows 7), it takes 12 ms. So why is the Visual Studio&#8217;s WebDev.WebServer so slow ?</p>
<p>By the way, why should we use a Linux + lighttpd + Mono server when we can use a Windows + IIS + ASP.Net server ? The reason is mainly that for the same usage, Linux consumes less resources and it&#8217;s easier to customize to suit your needs.</p>
<p>An other question you might have : Why use JQuery + JSON when you can use everything in the Microsoft AJAX Framework ? The main reason is that I really have the feeling to lose control with Microsoft AJAX Framework, I don&#8217;t like the huge automatically generated code. And it doesn&#8217;t make really fast web interfaces. With JQuery, everything goes faster and it&#8217;s way more simpler to understand (and debug).</p>
<p>Related :<br />
- <a href="http://dotnetslackers.com/articles/ajax/Using-jQuery-with-ASP-NET.aspx#953">Using JQuery with ASP.Net</a></p>
]]></content:encoded>
			<wfw:commentRss>http://florent.clairambault.fr/lighttpd-mono-asp-net-the-right-configuration/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced
Database Caching 1/21 queries in 0.008 seconds using disk: basic
Object Caching 908/939 objects using disk: basic

Served from: florent.clairambault.fr @ 2012-02-07 11:16:34 -->
