AJAX Real Time and collaborative
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 a开发者_如何转开发re other options?what is the best way to this?
And with way number 2,this true I can do this only with IE8?Yosy
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
, and bayeux
. Dojo has a good implementation.
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".
精彩评论