AJAX 实时且协作
我正在尝试创建实时协作应用程序,例如 - google wave。 当用户 1 同时写入内容时,它会显示在用户 2 的屏幕上。
我开始了一些研究,并找到了一些使用 Ajax 的方法 -
1.每 X 秒向服务器发送请求并检查“发生了什么”
2.超时 - 长请求,问题 - 我看到我只能用以下方法做到这一点IE8
还有其他选择吗?最好的方法是什么?
方法2,这是真的吗?我只能用IE8来做到这一点?
约西
I am trying to create real-time and collaborative application like - google wave for example.
When user1 writes something at the same time it shows on user2 screens.
I started a little research,and found some ways to this with Ajax -
1.every X seconds send request to the server and to check what is "happening"
2.timeout - long request ,Problem - I saw i can do this only with IE8
there are other options?what is the best way to this?
And with way number 2,this true I can do this only with IE8?
Yosy
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
AJAX 的重点是服务器可以等待来自每个客户端的通知,并在发生情况时通知所有其他客户端。没有必要进行民意调查。查找关键字,例如
comet
和bayeux
。 Dojo 有一个很好的实现。The whole point of AJAX is that the server can wait for notifications from each clients, and notify all the other clients when something happens. There's no need for polling. Look up keywords like
comet
, andbayeux
. Dojo has a good implementation.我不确定你在 2 中指的是什么,但如果我要实现这样的东西,我会按照你在 1 中解释的那样做。基本上你的服务器将跟踪对话,并且客户端将不断地询问更新。
另一种可能的选择是闪存,但除了它的功能之外,我对此了解不多,因此您需要自行研究。
关于选项 1 中保持快速运行的一些注意事项:
记住你只有 2 个“ajax”
在客户端进行的调用(您只能有 2 个调用
立刻出来)。所以跟踪一下
已拨出的呼叫数。利用
如果调用时间太长或其响应不再有效,则使用 abort() 。
充分利用您的通话,如果
您需要将文本发送到服务器,
使用响应来获取更新
当前的“对话”。
I'm not sure what you are referring to in 2, but if I were going to implement something like this, I'd do what you explain in 1. Basically your server will be keeping track of the conversation, and the clients will constantly ask for updates.
Another possible option would be flash, but I don't know much about that other than it would be capable, so your on your own for researching that.
Some notes on keeping things running quickly in option 1:
Remember you only have 2 "ajax"
calls to work with on the client side (you can only have 2 calls
out at once). So keep track
of the calls that are out. Make use
of abort() if a call takes too long or its response is not going to be valid anymore.
Get the most out of your calls, if
you need to send text to the server,
use the response to get an update on
the current "conversation".