我希望向我的网站添加聊天功能,以便我的网站的用户可以互相聊天。我在网上找到的大多数聊天小部件(例如 此处)都允许在站点管理员和用户(出于客户支持的目的)。与客户支持相反,我希望网站上的聊天作为最终功能。我可以使用一个小部件来执行此操作吗?我正在寻找最简单的方法来做到这一点。任何指向正确方向的指针都会有所帮助。
谢谢!
I'm looking to add chat functionality to my site so that users of my site can chat with one another. Most chat widgets I have found online (i.e. such as the ones here) allow for chat between site administrators and users (for the purpose of customer support). As opposed to customer support, I want chat on my site to serve as an end functional feature. Is there a widget I can use to do this? I am looking for the simplest possible way to do this. Any pointers in the right direction would be helpful.
Thanks!
发布评论
评论(1)
如果这是小规模的,您不会有数百个用户,您可能需要从以下解决方案开始:
http://net.tutsplus.com/tutorials/javascript-ajax/how-to-create-a-simple-web-based-chat-application/
这里的关键是用户一边是语句:
setInterval(loadLog, 2500);
这是用户在 Javascript 中每 2.5 秒检查一次是否有新内容的地方。将其设置得更高,它不会经常检查,但也不会经常用 PHP 代码对服务器造成错误。该解决方案很容易实现,但也有一个弱点,如果它太流行,您的服务器主机可能会收到太多请求,超出其处理能力。
If this is low scale, where you aren't going to have hundreds of users, you may want to start with this solution:
http://net.tutsplus.com/tutorials/javascript-ajax/how-to-create-a-simple-web-based-chat-application/
The key here on the users side is the statement:
setInterval (loadLog, 2500);
This is where the users end in Javascript checks out if there is anything new every 2.5 seconds. Set it higher, and it won't check as often, but it also won't bug the server with the PHP code as often. This solution is easy to implement, but also has the weakness that if it gets too popular, your server host could get too many requests than it can handle.