Ahh - a stateful server daemon to maintain a stateful session on behalf of a non-stateful client - and herein lies the problem.<br><br>Sounds like a job for one of the Jabber c libraries - I'm sure google accomplishes this through Python (which gmail is written in) or a compiled language.<br>
<br>Here's some code to get you started ... (borrowed from apache)<br><br>for ( ; ; ) {<br> // your session code<br>}<br><br>Although I don't agree PHP is a wasteland - PHP as an SAPI (which is what you are referring to) wasn't designed to have it's execution piped to waiting or stateless threads from user requests through DMA unfortunately - However the PHP thread is capable of leaving open 'persistant' connections<br>
<br>pfsockopen();<br><br>I'm not an expert on the XMPP / Jabber protocols but I've implemented other persistent connections (such as terminal emulation) across requests using persistent sockets... I have to guess that's how xmpphp is implemented (it would hopefully not suffer the log out, log in) issues you are describing across requests.<br>
You've actually spiked my curiousity so I'm going to look into the protocol more, as implementing a decent chat client is something I've always wanted to do but just haven't really had a need.<br><br>A completely different approach is to open a PHP thread for each jabber login request received - then ignore user abort, and have the thread query a database on a regular basis to determine if the connection should be closed based on timeout / user abort. <br>
The never ending thread would persist for each user, and it may be smart to set the maximum memory size to something pretty small so if there are hundreds of simultaneous users PHP doesn't reserve all the systems memory across all of the possible threads.<br>
You might even be able to consolidate ALL users to one never ending thread on the server and just conditionally open and close as many different sockets as needed based on queries to a database.<br><br>Yet another and probably more elegant solution is to perform interprocess communication to a persistent php thread using sockets and the socket_create_pair() function.<br>
<br>So when PHP get's namespaces and lambda functions in 6.0 will it be promoted to an oasis? Oh I can't wait to be Y combinating in my wasteland.<br><br>The real issue is that almost all PHP opensource applications have the goal of reaching the largest audience - with that goal comes the requirement to run on shared hosts, and with that comes the lack of applications that interact with or are concerned with persistent services such as XMPP; thus the wasteland.<br>
<br>But I digress... <br><br><div class="gmail_quote">On Wed, May 27, 2009 at 5:06 PM, Ben Rousch <span dir="ltr"><<a href="mailto:brousch@gmail.com">brousch@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I have done some (very) small experiments on something similar to what you're asking for. I did not really look for any sort of robust middleware.<br><br>I used the Jive/OpenFire/Ignite Realtime (Whatever their name is these days) Smack Java library to create a xmpp client/bot. A user would chat with my xmpp bot, and the bot would process their commands and store the results in a database. I then used LAMP and AJAX to poll the database and post on a web site.<br>
<br>_______________________________________________<br>
grlug mailing list<br>
<a href="mailto:grlug@grlug.org">grlug@grlug.org</a><br>
<a href="http://shinobu.grlug.org/cgi-bin/mailman/listinfo/grlug" target="_blank">http://shinobu.grlug.org/cgi-bin/mailman/listinfo/grlug</a><br></blockquote></div><br>