 private let chikuranUrl = "http://www.chikuwachan.com/live/"
 private let maxPage = 5
 
-final class RankingManager {}
+final class RankingManager {
+    private var isRequesting = false
+}
 
 extension RankingManager: RankingManagerType {
     func queryRank(liveId: String, completion: @escaping (Int?) -> Void) {

                case .failure(let error):
                    log.error(error)
                    completion(nil)
                }
            }
    }


private extension RankingManager {
    func queryRank(liveId: String, page: Int, completion: @escaping (Int?) -> Void) {
        guard !isRequesting else {
            // Previous request is still in progress, reject the query.
            completion(nil)
            return
        }
        guard let urlString = rankingUrlString(for: page),
              let url = URL(string: urlString)
        else {
            // Query reached to max page, quit to further requesting.
            completion(nil)
            isRequesting = false
            return
        }
        isRequesting = true
        var request = URLRequest(url: url)
        request.headers = [commonUserAgentKey: commonUserAgentValue]
        AF.request(request)
