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.