是否有没有服务器端修改不需要轮询的Ajax的替代方法? [英] Is there an alternative of ajax that does not require polling without server side modifications?

查看:90
本文介绍了是否有没有服务器端修改不需要轮询的Ajax的替代方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个基于小型和基本的ajax的多人游戏。对象的坐标由PHP处理程序给出。这个handler.php文件每200MS轮询一次,通过使用ajax。



由于在没有任何事情发生时不需要轮询,我想知道有没有什么可以做的没有经常轮询的同样的事情?例如。彗星,但我听说你需要为Comet配置服务器端应用程序。这是一个共享的网络服务器,所以我不能这样做。



也许可以防止handler.php文件甚至在客户端无需更改任何响应时返回响应,那可能吗?然后,即使有些东西没有改变,你仍然会让客户无用地要求回应。基本上,它应该只使用带宽和切断资源,如果需要告诉客户端,例如。这是一个解决方案 - 使用SaaS慧星提供程序,例如 WebSync On-Demand 。没有服务器资源需要担心,共享主机与否,因为它已全部卸载,并且可以根据需要推送信息。



因为它是SaaS,所以它可以工作与任何服务器语言。对于PHP来说,已经有一家发布商已经编写好了并准备好了。


I'm trying to create a small and basic "ajax" based multiplayer game. Coordinates of objects are being given by a PHP "handler". This handler.php file is being polled every 200MS, by using ajax.

Since there is no need to poll when nothing happens, I wonder, is there something that could do the same thing without frequent polling? Eg. Comet, though I heard that you need to configure server side applications for Comet. It's a shared webserver, so I can't do that.

Maybe prevent the handler.php file from even returning a response if nothing has to be changed at the client, is that possible? Then again you'd still have the client uselessly asking for a response even though something hasn't changed yet. Basically, it should only use bandwidth and sever resources if something needs to be told to the client, eg. the change of an object's coordinates.

解决方案

Here's a solution - use a SaaS comet provider, such as WebSync On-Demand. No server resources to worry about, shared hosting or not, since it's all offloaded, and you can push out the information as needed.

Since it's SaaS, it'll work with any server language. For PHP, there's already a publisher written and ready to go.

这篇关于是否有没有服务器端修改不需要轮询的Ajax的替代方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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