English 中文(简体)
我是否能够用闪电改进阿富汗复兴和重建联盟?
原标题:Can I improve AJAX with Flash?
  • 时间:2009-08-31 12:46:10
  •  标签:

我在网上游戏,每秒打几台服务器。 复兴共和与民主军的电话是好的,但是这些电话仍然比正常的非加太集团/IP-电话连接要慢。

因此,我的问题是,如果能够利用闪电,能否改进我的游戏? 或许还有某种解决办法是代谢(70%的用户使用)?

最佳回答

刚刚来到这个对你有帮助的新联合材料图书馆(今天由ajaxian ):

<Kamaloka

现场:

Kamaloka-js 是在 native本实施阿格米克方案信息发布协议。 安装在轨道上,但可以与在浏览器上制作类似于轨道的投放器上的部队派遣国和部队派遣国的图书馆一起使用。


另一种类似的解决办法(利用闪电):amqp-js

问题回答
  1. Create a Flash file that handles your game calls via the built-in XMLSocket objects
  2. Hide that flash in your HTML (width/height = 1)
  3. Use flash.external.ExternalInterface.call from Flash to call JS functions

通过<代码>External Interface的闪电/JS通信速度非常快,可以处理由袖珍答复提供的速度。

我希望这一帮助。

在进行这种优化之前,你不妨首先介绍,以确保缓慢部分是javascript与服务器之间的袖珍连接。

我倾向于介绍服务器的方面,然后从javascript到服务器和背面,而差异是由于袖珍连接。

一旦你们有一定数目,那么你所作的任何其他变化,如Makram所建议的变化,就可以说明情况,看看看是否取得了足够的改进。

If your calls to the server are some sort of polling you can look at using Comet to help with that: http://en.wikipedia.org/wiki/Comet_%28programming%29

如同詹姆斯·布莱克所说,在你发现瓶颈的地方(如果有)之前,不会直线跳出来,把所有东西都用掉。

我认为,从一些评论来看,你可能还失踪。

我想在你的来文中阐述所有各层次,只是要明确一点——一点是,它不大可能是问题,而你只想看问题。

  1. Client code - currently javascript, which calls the next layer asynchronously. If you optimize to Flash, this part may be more responsive, and its "richer".
  2. TCP/IP (wont go lower than that) - this is ALWAYS stateful, because TCP is stateful. At least at the connection layer... What this means, is that usually the TCP connection is kept open for a long time, and you dont open a new one on each request. You won t be changing this in a browser app...
  3. HTTP - stateless in principal, but typically circumvented through some form of cookies and server-side session. Also it s not the MOST efficient protocol, especially for binary data, since it is text-based and a bunch of overhead. While it is technically possible to skip through this protocol, its highly UNrecommended to do this in a browser app, because (a) its unexpected from a user point of view, and (b) its not very firewall friendly.
  4. XML - if you discover that your bottleneck is in the amount of data transmitted, you might just want to switch out the payload format since XML is pretty verbose. For example, JSON would be a great alternative here. Or maybe just trim down the XML schema...
  5. Server side app - often, the bottleneck will be here, regardless of anything that happens downstream.

So, to sum up - switching your client to Flash might have 2 possible benefits: the client itself may run faster (depending on your client), and it allows you to call sockets directly bypassing 3 above (http). Again, note that the 2nd benefit is dubious at best - benefit is questionable, and there are clear downsides to it.
Unless the bottleneck is the client display code, you re better off either switching to JSON (or other data format), or optimizing your server code. Once you profile and figure out where the problem is, you ll better know where to focus your efforts. I find it highly unlikely that Flash will help with that. (again, since it IS a game, you may need the improved display).

If you do this, please make sure you do something sensible when the user has a proxy configured, even if it s just a message telling the user that proxies aren t supported.

轴心很容易忘记。





相关问题
热门标签