Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Volley什么时候重发请求 #1

Open
LNeway opened this issue Apr 8, 2016 · 0 comments
Open

Volley什么时候重发请求 #1

LNeway opened this issue Apr 8, 2016 · 0 comments

Comments

@LNeway
Copy link

LNeway commented Apr 8, 2016

不知道楼主现在是否记得请求重发这一块的逻辑,看源码找了半天都没有找到

/** * Prepares for the next retry by applying a backoff to the timeout. * @param error The error code of the last attempt. */ @Override public void retry(VolleyError error) throws VolleyError { mCurrentRetryCount++; mCurrentTimeoutMs += (mCurrentTimeoutMs * mBackoffMultiplier); if (!hasAttemptRemaining()) { throw error; } }

上面这块代码是 NetworkDispatcher 中 run方法的实现

下面是DefaultRetryPolicy里面当中的代码,但是在这个代码中没有看到它把请求添加到请求队列当中。

request = null; try { // Take a request from the queue. request = mQueue.take(); } catch (InterruptedException e) { // We may have been interrupted because it was time to quit. if (mQuit) { return; } continue; }

这个请求在真正发送之前就从队列里面拿出来了,但是在重试的时候又没有放进去。

所以请教一下楼主知不知道Volley请求重发的核心代码,谢谢!

需要重发的请求是否放到了请求的队列当中,如果放进去了是在哪里放进去的,如果没有放到请求队列当中,那么这个重发的请求又是如何实现的?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant