Robospice retry policy custom implementation

╄→尐↘猪︶ㄣ 提交于 2019-12-13 05:13:45

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/31463465/robospice-retry-policy-custom-implementation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!