Robospice retry policy custom implementation

2019-09-09 02:21发布

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条回答
一纸荒年 Trace。
2楼-- · 2019-09-09 03:06

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

查看更多
登录 后发表回答