Re: Creating A Chat?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Tedd,

This is where there is a need for some "magic".

In the case of Stuart, he wrote a "fastcgi" script. Basiacally, this
handles the Ajax calls.
Each call uses "long polling": the server is not responding directly.
Instead, it keeps the connection open to the fast-cgi script.
In order to know how many users are online, you just have to count how many
connections are open to the fastcgi script.

Then, since the connections are open, still waiting for a reply, the
fastcgi script just forwards the message it receives on all open
connections.
This message is parsed by the Javascript script on the client side, and the
Javascript script on the client side adds the message on the screen.

There are other ways to do this. I've been doing this in a pure PHP way
with Xaja (without the need of using fastcgi, with just PHP and Apache).
There is an explanation going on here:
http://www.thecodingmachine.com/ext/xaja/doc/about/architecture.html
Maybe it will make things more clear.

Regards,
David.


On Tue, 21 Apr 2009 12:10:48 -0400, tedd <tedd.sperling@xxxxxxxxx> wrote:
> At 5:14 PM +0200 4/21/09, David Négrier wrote:
>>Here is a quick explanation of what is going on behind the scene:
>>
>>-snip-
>>
>>Regards,
>>David.
> 
> Thanks -- I think I know what's going on. I've 
> done sufficient ajax to know what's going on. 
> However, what I don't understand is:
> 
> 1. Detecting who is currently online (i.e., all 
> who are connected to THE server);
> 
> 2. And then how to send all of them stuff.
> 
> For example, if you have four people connected to 
> the server at the same time and one sends 
> something, then how do you forward that to each 
> person so that their screen refreshes accordingly?
> 
> Cheers,
> 
> tedd

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux