Pokemon-Go-Rocket-API icon indicating copy to clipboard operation
Pokemon-Go-Rocket-API copied to clipboard

What is the meaning of IApiFailureStrategy and how should i get it to work?

Open RickardPettersson opened this issue 9 years ago • 3 comments

I trying to get login to work with latest code and there is a new parameter to the Client for a IApiFailureStrategy object.

How did you like us to use it?

RickardPettersson avatar Aug 02 '16 07:08 RickardPettersson

I think the general idea of it is that you can setup different number of retries. But for me it seems like a work in progress because it doesn't really allow to handle different failures.

Da-Teach avatar Aug 02 '16 09:08 Da-Teach

i can not get latest code to work becouse of i dont understand what i should return as value then the enum not works to return in the function named HandleApiFailure in the ApiFailureStrategy

RickardPettersson avatar Aug 02 '16 11:08 RickardPettersson

You can handle the failures.

Here is a example code:


    internal class APIFailure : IApiFailureStrategy
    {
        public async Task<ApiOperation> HandleApiFailure(RequestEnvelope request, ResponseEnvelope response)
        {
            await Task.Delay(500);
            return ApiOperation.Retry;
        }

        public void HandleApiSuccess(RequestEnvelope request, ResponseEnvelope response)
        {

        }
}

I dont handle the error, just await and try, try again.. and when success, i do not anything xD

Corlobin avatar Aug 02 '16 12:08 Corlobin