Adobe Actionscript - 多个服务请求处理
有谁知道有什么好的资源可以充分解释在同时发生多项事情的 Adobe AIR 应用程序中如何触发功能和结果?
作为一个简单的测试,我创建了一个服务,我只是不断更改其 url,然后发出 send()。似乎无论我输入多少次 send() 调用,所有这些调用都会在第一次调用“结果”eventListener 函数之前执行。
是这样的吗?即当前函数完全执行,异步返回在 AIR 完成当前正在执行的操作后排队等待处理。
同样,如果用户在所有这一切发生时做了某事,我认为他们的请求也会进入队列的后面?
所有这些都是有道理的,但我只是想知道它是否在任何地方都有记录。
当我使用一种方法时,是否建议采用这种方式重用相同的 HTTPService,还是为每个并发事务创建一个更好?仅仅因为它有效,并不意味着它是正确的做法......
Does anyone know of any good resources that fully explain how functions and results will fire in an Adobe AIR app where multiple things are happening at once?
As a simple test, I've created a single service that I just keep changing the url of, then issuing a send(). It seems that no matter how many send() calls I put in, all of these get executed before the 'result' eventListener function gets called for the first time.
Is this how it works? i.e. the current function gets fully executed, with the async returns queueing up to be processed after AIR has finished what it's currently doing.
Likewise, if the user does something while all this is going on, I presume their request goes to the back of the queue as well?
All that makes sense, but I'm just wondering if it's documented anywhere.
While I'm on one, is it recommended practice to reuse the same HTTPService in this way, or is it better to create one for each concurrent transaction? Just because it works, doesn't mean it's the right thing to do...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不知道有任何文档解释了这一点,但我可以确认代码块在进行异步调用之前或至少在处理结果之前执行。如果它不能以这种方式工作,您将无法始终将响应程序附加到服务调用的令牌,因为结果可能已经被处理。
来自其他平台的开发人员觉得这很奇怪,因为他们认为响应者的分配为时已晚。
因此,虽然我没有关于 Flash Player 内部技术细节的官方解释,但我可以保证它是这样工作的。
如果用户在呼叫挂起时执行某些操作,则新请求实际上只会添加为新的异步呼叫。请注意,我们不能真正谈论队列,因为不能保证第一个调用的响应在第二个调用的响应之前到达。这取决于实际请求花费的时间。
您可以完美地重用 HTTPService 实例。
PS:基于此,我们能够构建 Spring ActionScript 中的操作 API。它基本上是一个 API,允许您以统一的方式执行异步流程,而不必担心实际异步流程的细节。
以下代码执行异步进程并向其附加处理程序。这也是很多开发者一开始感到困惑的事情,原因与 asyncToken 的情况类似。
I'm not aware of any documentation that explains this, but I can confirm that code blocks get executed before async calls are made, or at least before their result is being processed. If it didn't work that way, you would for instance not always be able to attach a responder to a token of a service call, because the result might already have been processed.
Developers coming from other platforms find this strange as they would expect the assignment of the responder to be too late.
So while I don't have an official explanation about the technical details inside the Flash Player, I can assure that it works this way.
If the user does something while a call is pending, the new request will indeed just be added as a new asynchronous call. Note that we can't realy speak of a queue, as there is no guarantee that the response of the first call comes in before the response of the second call. This depends on how much time the actual requests take.
You can perfectly reuse an HTTPService instance.
PS: Based on this, we were able to build the Operation API in Spring ActionScript. It is basically an API that allows you to execute asynchronous processes in a uniform way, without having to worry about the details of the actual async process.
The following code executes an async process and attaches a handler to it. This is also something that puzzles many developers at first, for reasons similar to the asyncToken situation.