阿贾克斯聊天轮询带宽效率 [英] Ajax chat polling bandwidth efficiency

查看:124
本文介绍了阿贾克斯聊天轮询带宽效率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一个小型Web应用程序基本上是在浏览器中一个jQuery供电的聊天客户端,以获得职位,我轮询服务器一个AJAX请求,然后追加任何新的答复,我很担心会这种尽可能提高效率,而不是失去了实时的感觉。

I've written a small web application which is basically a JQuery powered chat client within the browser, to get the posts I'm polling the server with an AJAX request and then appending any new replies, I'm worried about making this as efficient as possible while not losing the realtime feel.

http://darklightweb.co.uk/RealTime/

我看不到任何方式中断是可能的,所以我投票的网页每5秒,返回什么,如果没有新的职位都可以让数据传输下来,如果它的闲置,如果它确实有一个信息顶部队列中的消息被发送出去,我再次检查,一旦Ajax请求已完成,直到消息队列为空。

I can't see any way that interrupts are possible so I am polling a page every 5 seconds that returns nothing if no new posts are available to keep data-transfer down if it's idle, if it does have a message the top message in the queue is sent out and I'm checking again as soon as the Ajax request has finished until the message queue is empty.

任何其他提示进行此为低带宽尽可能或可能的替代实现?

Any other tips on making this as low-bandwidth as possible or possible alternate implementations?

推荐答案

轮询可能无法实现聊天的最佳解决方案 - 我建议采取一看的的jQuery的实施 COMET 这使打开的连接到客户端,并推动从服务器更新向下,也是的相当可扩展

Polling might not be the best solution for implementing a chat - I'd suggest taking a look at JQuery's implementation of COMET which keeps an open connection to the client and pushes updates from the server 'down' and is also quite scalable.

这篇关于阿贾克斯聊天轮询带宽效率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆