Jump to content

instant messaging


chiprivers

Recommended Posts

I want to create a simple instant messaging script for my daughter to chat with her friends online within a secure enviroment that I can control.  I can build the majority of this using PHP and MySQL and wondering how I can make it update with new messages as they are ready? I have googled this but all I can find is full scripts, all I need is to know is the bit to get the messages in real time!

Link to comment
https://forums.phpfreaks.com/topic/79004-instant-messaging/
Share on other sites

Hmm, sounds like if I gave you a nudge, you'd instantly would be able to follow up.

 

Check up on AJAX and PHP. AJAX uses javascript calls to PHP pages to obtain data. It's a very simple, clean method that can be used to retrieve new messages by having the PHP page run the query and return any new messages.

Link to comment
https://forums.phpfreaks.com/topic/79004-instant-messaging/#findComment-399809
Share on other sites

You have to have a refresh value for the chat window, since PHP is server-side. The refresh searches the database for new messages based on a timestamp. This would be fairly complicated logic and programming, not to mention mission-critical. You would need to use document.write to really do this smoothly.

 

The other way is to pull all messages, and send n number of them to the chat window. Messages are removed from the database every n number of minutes so that only recent messages are in there. This is certainly not very efficient, but workable.

 

I feel you may be re-creating the wheel here, as there are TONS of free IM/Chat scripts around, including some nice Flash ones. PHP developed chat screens tend to be poor environments, since you have to constantly refresh the page, which unless the user has navigation clicks turned off in their settings, produces a click every 5 or 10 seconds depending on refresh rate. You really need AJAX or Flash to get around all the caveats associated with server-side chat scripts.

 

PhREEEk

Link to comment
https://forums.phpfreaks.com/topic/79004-instant-messaging/#findComment-399817
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.