简体   繁体   中英

How can I create a chat application in PHP/Javascript?

I'm trying to create a chat system using PHP and javascript. I want to know how the chat in Gmail works: it will remain in the same position even as the user moves to another page. I would be grateful if anyone could explain how it works.

And at the same time, please give some ideas on how to create a chat s/m. For example, the creation of the popup window, protocols to be used with chat, etc.

The chats in GMail, Facebook or Orkut stay at their same position even when you change pages thats because they are not doing a real page change when you click on any link inside GMail or Facebook or orkut. They load the page by means of a hash tag identifier and load the contents using standard AJAX. For example inside GMail you would find all links like inbox as https://mail.google.com/mail/?zx=xxxxxxx&shva=1#inbox and https://mail.google.com/mail/?zx=xxxxxxxx&shva=1#starred so when you click on them the browser doesn't actually reload a new page instead makes an AJAX request and pulls data in, hence this doesn't affect the chat block on the page.

You can have a look at http://www.ajaxprojects.com/ajax/tutorialdetails.php?itemid=9#start for a simple PHP/MySQL based chat application. If you want a scalable chat application you have to go in Comet or "Bidirectional-streams Over Synchronous HTTP" BOSH. Friendfeeds TornadoWeb in python can help. http://www.tornadoweb.org/

Hope this info helps.

I understand that you want to create a "Chat system",

Gmail's chat is not an isolated system, it is closely integrated/Synced with Gtalk , (do you plan on providing a Desktop app as well as a web interface?)

Secondly Gtalk/Gmail chat uses a custom protocol(although it is open..meaning you can write your own Gtalk clients as well).

For your "Chat System", if you want it to be as nice as Gmail's you'll definitely need to use

AJAX and JSON along with Java Script and PHP

AJAX will help you to create Eye Catching at the same time responsive UI and and JSON will help you to transport data along the wire.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM