Robospice重试政策自定义实现 [英] Robospice retry policy custom implementation

查看:209
本文介绍了Robospice重试政策自定义实现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要实现这样的行为。喜欢的东西的时间了一段时间轮询远程Web服务器,从服务器响应为条件检查,例如可变的条件。结果
更具体地,考虑一个例子。我需要在5分钟,然后不轮询服务器每5 secodns。有一个在Robospice图书馆很大的特点 - RetryPolicy,几乎我需要什么结果。
我有 getRetryCount,getDelayBeforeRetry 方法。正是我需要实现我的任务。结果
但我需要执行时重试结果code是 HTTP ::确定。因此,在这种情况下,我必须让我的拖延里面的活动,并从那里发送新的请求,这将是更好的这种逻辑一些其他类中,并在服务中分离出来。结果
所以,我需要一些中间件来处理来自服务器的响应。结果
我不Robospice库完美,所以也许已经有没有办法做到这一点。结果
请建议要做到这一点的最好办法,谢谢你。

I need to implement such behaviour. Something like polling remote web server for the some period of time, checking for the condition in response from the server, for example variable condition.
To be more specific, consider an example. I need to poll server every 5 secodns during 5 minutes and than fail. There is great feature in Robospice library - RetryPolicy, nearly what I need.
I has getRetryCount, getDelayBeforeRetry methods. Exactly what I need to implement my task.
But I need to perform retries when result code is HTTP::OK. So in this case I have to make delays inside my activities, and send new request from there, it would be better to separate this logic inside some other class and in the service.
So I need some middleware to handle responses from the server.
I don't Robospice library perfectly so maybe there is already any way to do this.
Please suggest the best way to do this, thank you.

推荐答案

您也许可以实现通过使用RoboSpice的OkHttp扩展。查看<一个href=\"https://github.com/octo-online/RoboSpice-samples/blob/master/robospice-sample-okhttpclient/src/com/octo/android/robospice/sample/okhttp/ReverseStringRequest.java\"相对=nofollow>这个例子获取在较低的水平响应分析。

You can probably achieve that by using the OkHttp extension of RoboSpice. Check out this example for response analysis at a lower level.

这篇关于Robospice重试政策自定义实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆