Creating PHP in-time live chat

What's the best way to create live chat that will be used between the website members?

The live chat should work in-time.
LVL 12
Mohamed AbowardaSoftware EngineerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mr_egyptianCommented:
In time for what? Do you want to roll your own for some reason?

There are plenty of pre-existing chat scripts available.

http://www.phpfreechat.net/
http://www.phpopenchat.org/
http://www.php-development.ru/javascripts/ajax-chat.php
0
Mohamed AbowardaSoftware EngineerAuthor Commented:
I don't want chat room, I want live chat that can be used between any two members on the website.

The main thing I am looking for is "the best idea that fit what I want".

Do I need to use AJAX to frequently make request for updates? or use ob_flush which I think it will cause processes problem.
0
leakim971PluritechnicianCommented:
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Mohamed AbowardaSoftware EngineerAuthor Commented:
@leakim971: As I mentioned, the first thing I am looking for in this question is "the best idea", I can do everything myself, I only need the best idea that will not greatly affect on the server processor.
0
leakim971PluritechnicianCommented:
0
Mohamed AbowardaSoftware EngineerAuthor Commented:
@leakim971: I must do everything myself without using third parties other than jQuery.

I would appreciate if you could post how it works without using HUGE server resources.
0
leakim971PluritechnicianCommented:
Currently Comet work fine with long polling (use of ob_flush)
With long polling you reduce the number of request between server and the browser
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Mohamed AbowardaSoftware EngineerAuthor Commented:
@leakim971: You suggest using ob_flush, however I don't want to use any third-parties, would you recommend me to use ob_flush?

If Yes, please post sample PHP code for live interaction between the server and two clients.
0
leakim971PluritechnicianCommented:
For example : http://www.metal3d.org/index.php/blog/ticket/2009/12/13/Serveur-Comet-ou-Long-polling-avec-Ajax?heading=Informatique

if you need help understand the comment, don't hesitate, I'm french
0
Mohamed AbowardaSoftware EngineerAuthor Commented:
@leakim971: I need to understand the idea, how it actually works in facebook?
0
leakim971PluritechnicianCommented:
0
Mohamed AbowardaSoftware EngineerAuthor Commented:
@leakim971: Do you think that making HTTP request over a persistent connection till it receive data can cause high load on the apache server if there are alot of users using the chat at the same time?

For example: In the case there are 100,000 user using that chat at the same time, I think it will create 100,000 process running at the same time since the persistent connection will keep the script running until there is data to return to the client.
0
Mohamed AbowardaSoftware EngineerAuthor Commented:
Another thing, when the data received from client A while client B is waiting, how to transfer the data to client B?
0
ZupremeCommented:
If I HAD to write my own module I would:

1) Create a "messages" database and table with rows, "id,sender,message
2) Create a PHP page that returns all results from that table
3) Create a PHP page to calculate the total number of records, to simply submit entries to that table if there are fewer than 100 results, or to delete all results older than the most recent 100 (defined by unique auto increment id)
4) Create an AJAX function to call the page created in step 2 every x seconds (you can adjust the interval according to your preferences).


This will take a big toll on you resources, but should be workable if you don't have a very high-traffic site.
0
Mohamed AbowardaSoftware EngineerAuthor Commented:
@Zupreme: What If I have very high traffic on the website?
0
Mohamed AbowardaSoftware EngineerAuthor Commented:
Thanks,
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.