Web Chat Application using Long-Polling Technology with PHP,MySQL and jQuery [closed]

情到浓时终转凉″ 提交于 2019-12-05 05:52:11

问题


We are using a chat system in our company which is build in Ajax, PHP and jQuery. Currently it refreshing in every second both in admin end and user end to pull data from mysql. Which makes the system inefficient and slower.

I want to pull data from mysql only when an user or admin send a message. But the problem is : How I will check from admin end that an user send a message (in real time)? Is it possible in Ajax to send data/request 2 different PHP pages simultaneously in real time? This may be a solution.

Or Any Idea to make efficient chat system? We don't want to use any third party chat solution. Any Idea/help will be highly appreciated.

Thanks,
Rejoanul Alam


回答1:


jQuery Long Polling

This is possible by jQuery/PHP/MySQL with long polling. A sample implementation available in this url: http://sugunan.com/sites/chat/chatterFront.html

Open this in two different browser or machines. And provide the name and start the chat.

The source code of this chat tool can be downloadable at this url: http://www.sugunan.com/sites/chat/source.zip

Node.js

If you are owning the server you can go for node.js faye based implementation: http://faye.jcoglan.com/node.html

This is a push notification technology. So it wont ping the server frequently. But it will deliver the message instantly. It can be integrated with PHP if you want to persist the message on server.




回答2:


Yes, there are some ways,
They are called comet, sometimes reverse ajax, google it ;)

on a shared hosting use long polling,
on dedicated host or VPS use sockets.



来源:https://stackoverflow.com/questions/25682913/web-chat-application-using-long-polling-technology-with-php-mysql-and-jquery

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!