开发类似于 Stackoverflow 的聊天 API [英] Developing Chat API like that of Stackoverflow
问题描述
如何开始开发聊天 api,就像 stackoverflow 使用的那样?如果是开源的,我在哪里可以找到它,如果没有,谁能指导我如何构建一个类似的聊天api?
How to begin developing chat api, like the one stackoverflow uses? If it is open source, where can i find it, if not can anyone guide me how to build a similar chat api?
推荐答案
现在是彗星时代.
Comet 是反向 ajax.如果您在聊天应用程序中使用 ajax,您需要每次检查数据库更新,但在 Comet 的情况下,它完全与服务器端事件有关.
Now its the time of comet.
comet is reverse ajax.If you are using ajax in chat applications u need to check everytime for database updations but in the case of comet its all about server side events.
我们可以在@server端设置某些事件,然后它会在数据库更新时自动更新网页.也就是说,我们不需要一直发出请求.
We can set the certain events @server side then it will automatically update the webpage when the database is getting updated.that is we do not need to give requests all the time.
这样我们就可以避免由于大量请求而导致的服务器头痛,并且应用程序会非常快.
So that we can avoid the server headache due to large number of requests and the application will be very much faster.
这是一个使用 Comet 的实时聊天示例.
检查一下:http://www.zeitoun.net/articles/comet_and_php/start
This is a live chat example using comet.
check it out: http://www.zeitoun.net/articles/comet_and_php/start
它超越了ajax
这篇关于开发类似于 Stackoverflow 的聊天 API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!