How do I create a chat server that is not driven by polling?

南楼画角 提交于 2019-12-05 13:13:43
txwikinger

How about push technology? see http://en.wikipedia.org/wiki/Comet_(programming)

I think you're describing XMPP over BOSH.

http://xmpp.org/extensions/xep-0206.html

I've used this http-binding method between a chat server and javascript client on non-mobile devices. It worked well for me.

You might like to check out this project which uses a variety of techniques including Comet. Release details are here, here's a snippet from that page

It’s my distinct pleasure to be able to announce the first public showing of a project that I’ve been working on in my spare time in the last month or two, a new Web Based IRC chat application.

This project brings together a lot of new technologies which had to be developed to make this a feasible, scalable and efficient.

Some of the underlying tools build to make this posible that i consider ’stable enough’ are already released, such as the php Socket Daemon library i wrote to be able to deal with hundreds up to many thousands of “Comet” http connections, and an equal amount of IRC client connections.

I just found this article myself, which describes the following technique (which I referred to in the question):

... have the client make an HTTP request and have the server hold the request on the queue until there is a message to push. if the TCP/IP connection is lost or times-out, the client will make a new HTTP request, and the delay will only be the round trip time for a request/response pair . . . this model effectively requires two TCP/IP connections for HTTP, client to server, though none permanent and hence mobile friendly

I think this is nearly impossible and dangerous. The internet works stateless and connectionless meaning that the connection between client and server is always handled as unreliable. And this is not for fun.

By trying to get a stateful connection you are introducing new issues. Especially from a 3g application. What if the connection breaks? You have no control over the server and cannot push.

I think it would even be easier to send sms/text messages and have an application that handles that.

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