Flex HTTPService 超时处理程序

发布于 2024-11-07 11:51:13 字数 580 浏览 0 评论 0原文

我的 Flex 应用程序在启动时发送一些并发请求。有时需要很长时间才能获取所有内容,因此我将它们的 requestTimeout 参数设置为 5 秒。此外,我还定义了一个处理故障事件的方法。我想在超时时重新发送请求。 但这不起作用。你能看一下代码吗?

protected function fatalErrorOccuredInfo(event:FaultEvent):void
{
    // get the operation
    var operation:mx.rpc.http.AbstractOperation = mx.rpc.http.AbstractOperation(event.target);

    operation.url += "?t=" + new Date().getTime();
    operation.useProxy = false;
    //this should resend a request that caused timeout
    operation.send();

}

我检查网络监视器中是否发送了新请求,但它没有显示任何内容:-(

任何帮助将不胜感激。

my flex application sends a few concurent requests on startup. Sometimes it takes a lot of time to fetch them all so I've set them requestTimeout param to 5 secs. Additionally, I've defined a method that handles fault events. I'd like to resend a request when timeout occurs.
It doesn't work though. Could you take a look at the code?

protected function fatalErrorOccuredInfo(event:FaultEvent):void
{
    // get the operation
    var operation:mx.rpc.http.AbstractOperation = mx.rpc.http.AbstractOperation(event.target);

    operation.url += "?t=" + new Date().getTime();
    operation.useProxy = false;
    //this should resend a request that caused timeout
    operation.send();

}

I check whether a new request is sent in Network Monitor but it doesn't show anything :-(

Any help would be much appreciated.

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

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

发布评论

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

评论(2

深爱不及久伴 2024-11-14 11:51:13

WebService 类有一个 < 一个href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/rpc/soap/mxml/WebService.html#getOperation%28%29" rel="nofollow">getOperation 函数返回 抽象操作

将它与 event.currentTarget.name 一起使用

所以这就像

var operation:mx.rpc.http.AbstractOperation = myWebService.getOperation(event.currentTarget.name);
operation.send();

我很不确定,但如果 operation.send() 没有到达结果事件,你可能会必须为 ResultEvent.RESULT 添加事件监听器

WebService class has a getOperation function which returns an AbstractOperation.

Use it with event.currentTarget.name

So it would be something like

var operation:mx.rpc.http.AbstractOperation = myWebService.getOperation(event.currentTarget.name);
operation.send();

I am pretty not sure but if operation.send() does not get to the result event, you might have to add an event listener for ResultEvent.RESULT

迷鸟归林 2024-11-14 11:51:13

我看到的一个问题是这一行

operation.url += "?t=" + new Date().getTime();

每次发出请求时都会附加“?t =”+ new Date().getTime();
尽管这不应该是您的主要问题,但它确实是一个问题。

private var operationURL:String = "someurl.com/page.php";
private function loadOperation( ):void{
  var operation:mx.rpc.http.AbstractOperation = mx.rpc.http.AbstractOperation(event.target);
  operation.url = operationURL + "?t=" + new Date().getTime();
  operation.useProxy = false;
  operation.send();
}

private var retryCount:int = 0
protected function fatalErrorOccuredInfo(event:FaultEvent):void{
  // don't want it stuck in an endless loading loop
  // 10 count is more then enough 
  if( retryCount < 10 ){
    this.loadOperation( );
    ++retryCount 
  }
}

另外,如果您安装了 FireFox,请获取名为 HTTPfox 的附加组件。
HTTPfox 将向您显示从浏览器发出的所有请求

One problem I see is with this line

operation.url += "?t=" + new Date().getTime();

Every time you make a request you append "?t=" + new Date().getTime();

Although that shouldn't be your main issue it is a problem.

private var operationURL:String = "someurl.com/page.php";
private function loadOperation( ):void{
  var operation:mx.rpc.http.AbstractOperation = mx.rpc.http.AbstractOperation(event.target);
  operation.url = operationURL + "?t=" + new Date().getTime();
  operation.useProxy = false;
  operation.send();
}

private var retryCount:int = 0
protected function fatalErrorOccuredInfo(event:FaultEvent):void{
  // don't want it stuck in an endless loading loop
  // 10 count is more then enough 
  if( retryCount < 10 ){
    this.loadOperation( );
    ++retryCount 
  }
}

Also, If you have FireFox installed get an add-on called HTTPfox.

HTTPfox will show you all requests made from the browser

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