如何同步 Red5 NetConnection 调用

发布于 2024-12-22 00:46:10 字数 131 浏览 3 评论 0原文

我正在使用 red5 和 flex 开发在线游戏。使用RTMP连接。我只使用了netConnection.call。我的问题是 red5 调用没有同步进行。有些电话突然打给客户,有些电话需要时间。我想让这个电话按顺序到达客户端。请帮助我任何人...

I am developing a online game using red5 and flex. using RTMP connection. I used only netConnection.call. my issue is the red5 calls are not coming synchronized manor. some calls are coming to client suddenly some calls are taking time. I want to make this calls reach to client side in order. please help me any one...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

旧时浪漫 2024-12-29 00:46:11

以下是我的意见,我相信有更好的方法可以做到这一点。

  1. 编写一个类,负责 NetConnection.call 的执行。在本课程中,请确保在上一课程完成之前没有进行任何调用。它保证了顺序,但减慢了执行速度。
  2. 编写一个类,使得: 应该有一个数据结构,也许是最简单形式的数组。数组包含保存调用顺序、回调函数和从服务器返回的结果的对象。当您调用方法时,请按调用顺序将这些调用添加到数组中。当您从服务器收到结果时,检查数组。如果之前的调用尚未返回,则将它们存储在数组中。如果之前没有待处理的调用,请调用您的回调函数“稍后调用但早于此”的任何函数,并从数组中删除该项目。

但是,(red5 中总是有一个但是),如果您的应用程序需要按顺序得到一些结果,也许您应该考虑您的架构。大多数时候,经过仔细考虑的事件处理机制可以消除需要或有序的结果。

Followings are my opinions, I'm sure there are far better ways to do this.

  1. Write a class that is responsible from NetConnection.call execution. in this class, make sure that no call is made before previous one is completed. It ensures the order, but slows execution.
  2. Write a class such that: There should be a data structure, maybe an array in its simplest form. Array contains objects that holds call order, callback function and result returned from server. When you call a method, add those calls into the array in calling order. When you receive a result from server, check the array. if previous calls are not returned yet, store them in array. If there are no previous calls pending, call your callback function any functions "called later but finished earlier that this" and remove that item from your array.

But, (there is always a but in red5), if your application needs some result in order, maybe you should consider your architecture. Most of the time, a carefully thought event handling mechanism removes the need or ordered results.

若无相欠,怎会相见 2024-12-29 00:46:11

Red5 提供了两个支持同步和多线程访问的应用程序适配器。要使用它们,只需在应用程序中扩展 org.red5.server.adapter.ApplicationAdapter 或 org.red5.server.adapter.MultiThreadedApplicationAdapter 即可。

Red5 offers two application adapters which support synchronized and multithreaded access. To use them, simply extend org.red5.server.adapter.ApplicationAdapter for sync or org.red5.server.adapter.MultiThreadedApplicationAdapter in your application.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文