Php one to one chat without RTMP

Hello experts , would it be consistent to develop ajax based one to one chat application with php & mysql like in facebook . I mean setting an interval that will ask for new messages via ajax and update chatbox if there is new message. Would this build work healthy ?

Or do i have to use FMS or Wowza for RTMP  ?
LVL 14
Ali KayahanFull Stack DeveloperAsked:
Who is Participating?
Ali KayahanFull Stack DeveloperAuthor Commented:
Ok after googling some hours i found that ajax push  should be used for such projects. And i ll use APE (Ajax Push Engine) as its free and seems easy to use.
Ali KayahanFull Stack DeveloperAuthor Commented:
maeltar thanks for you reply , but i dont ask for a chat script . I just wonder would it be healthy to use settimeout or setinterval to check new messages or should we use ajax push or RTMP instead?
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

Ali KayahanFull Stack DeveloperAuthor Commented:
In my question , i asked for a consistent one to one chat algorithm which is not possible to build with intervals as answerer points.
you can perfectly use your method and build a reasonably neat chat application, but it probably will not scale very good

if you change a little bit the algorithm so that your client is ALWAYS requesting the next line in the chat, you will end up with the same functionnality any complicated lib provides
- server-side, you need the script to wait until some input arrives
- client-side, you need to restart the polling as soon as you received the previous line
btw, all of the the so-called HTTP+js push libraries work in this way, since httpquery does not return the page's content before it receives EOF

you probably can work something better and reasonably scalable by reading the chat continuously in an (i)frame so you do not even need to restart polling between lines.
if you use this (i)frame to echo back to the user, you can as well guarantee all chat windows are the same
but then you need to work out something to make the scrollback buffer non infinite so your browser does not eat up all memory after some time
i'd go for this solution, and an additionnal meta tag so the browser refreshes the chat window from time to time, refilling it with a reasonable scrollback
you probably can work out a javascript that will trigger the refresh based on the size of the (i)frame's contents

for the record, a database is not needed to achieve this. a text file would be more than enough as long as you do not let it grow endlessly
Ali KayahanFull Stack DeveloperAuthor Commented:
@skullnobrains: thanks for your reply , what about APE (Ajax Push Engine) ? I built a nice chat application with it .It seems consistent and also works as standalone server .
i never coded with it, but it looks clean and has a pretty good reputation
i like to have the same language client and server-side
if i were you i'd take a minute to check wether the http part is really HTTP and not a specific semi-strange protocol that will break if you have proxies or possibly if you want to move to a regular web server
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.

All Courses

From novice to tech pro — start learning today.