异步HTTP请求,排队的请求

编程入门 行业动态 更新时间:2024-10-27 05:32:36
本文介绍了异步HTTP请求,排队的请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我以前开发的AppStore和我用 ASIHTT prequest 。是否有类似的东西为Android?

I have developed for appstore before and I used ASIHTTPRequest. Is there something similar for Android?

期待在做一些HTTP请求,这是排队和管理。这是我需要做的:

Am looking at making a few HTTP requests, which are queued and manageable. This is what I need to do:

  • 中建立一个队列可以说6 HTTP请求。​​
  • 当队列设置,与每个请求给我一个成功/失败的结果执行。
  • 如果一个请求失败,我不得不取消/清除整个队列的选项。
  • 如果在队列中的所有请求都成功,我能有另一个回调对整个队列的成功事件。
  • 另外,每个请求可以有一个重试次数;含义;我可以说每个请求可以重试时间N多,才可以返回一个失败。
  • ASIHTT prequest 的IOS是pretty的善于处理这一点。反正我有可以与Android做到这一点?我的大部分内容返回的XML和没有二进制数据。

    ASIHTTPRequest for IOS was pretty good at handling this. Is there anyway I can do this with Android? Most of my content returned is XML and no binary data.

    任何反馈是非常AP preciated。

    Any feedback is much appreciated.

    推荐答案

    你描述的不是太复杂打造。

    What you describe is not overly complicated to build.

  • 扩展java.util.Queue中
  • 创建负责处理所有需要跟踪的事件自定义监听器​​界面。
  • 允许一个监听器​​
  • 在自定义请求对象进行设置。
  • 您的自定义的队列将有一个线程来处理它自己的队列中的项目。
  • 根据您的具体要求,可能还需要额外的接口/监听器来传递回,使得初始请求对象的最终响应。
  • Extend java.util.Queue
  • Create custom "listener" interface which handles all the events you need to track.
  • Custom request objects that allow a "listener" to be set.
  • Your custom queue will have a thread to process items in it's own queue.
  • Depending on your exact requirements, you may also need an additional interface/listener to pass back the final response to the object that made the initial request.
  • 当添加对象到队列,队列会为自己设定的自定义请求对象的监听。

    When adding an object to the queue, your queue would set itself as the "listener" on the custom request object.

    在该事件发生在请求对象,事件方法将被监听对象上称为...的情况下排队......可以作出适当的反应。

    When the events happen in the request object, the event methods will be called on the listener object...in the case the queue...which can react appropriately.

    我怀疑是这样ASIHTT prequest并没有真正的Java / Android的存在,因为它不是一个很难解决的问题是在iOS。我可以在20分钟以下实施上述目的成一个功能组件。当然,如果你没有做过这样的事情之前,它可能需要更长的时间。

    I suspect something like ASIHTTPRequest does not really exist in Java/Android, because it's not as difficult a problem to solve as on iOS. I could implement the above objects into a functional component in 20 minutes or less. Of course, if you've not done something like this before, it may take you much longer.

    更多推荐

    异步HTTP请求,排队的请求

    本文发布于:2023-11-11 17:48:24,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1579140.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:HTTP

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!