Browse Source

refactor: 删除有问题的取消请求函数

drake 1 year ago
parent
commit
dafde9ea98
1 changed files with 1 additions and 39 deletions
  1. 1 39
      net/src/main/java/com/drake/net/okhttp/OkHttpExtension.kt

+ 1 - 39
net/src/main/java/com/drake/net/okhttp/OkHttpExtension.kt

@@ -25,8 +25,6 @@
 package com.drake.net.okhttp
 
 import com.drake.net.interceptor.NetOkHttpInterceptor
-import com.drake.net.request.tagOf
-import com.drake.net.tag.NetTag
 import okhttp3.OkHttpClient
 
 /**
@@ -38,40 +36,4 @@ fun OkHttpClient.toNetOkhttp() = run {
     } else {
         this
     }
-}
-
-/**
- * 取消OkHttp客户端中指定Id的请求
- * 如果使用的是Net创建的网络请求请使用[com.drake.net.Net.cancelId]
- */
-fun OkHttpClient.cancelId(id: Any?) {
-    id ?: return
-    dispatcher.runningCalls().forEach {
-        if (id === it.request().tagOf<NetTag.RequestId>()?.value) {
-            it.cancel()
-        }
-    }
-    dispatcher.queuedCalls().forEach {
-        if (id === it.request().tagOf<NetTag.RequestId>()?.value) {
-            it.cancel()
-        }
-    }
-}
-
-/**
- * 取消OkHttp客户端中指定Group的请求
- * 如果使用的是Net创建的网络请求请使用[com.drake.net.Net.cancelGroup]
- */
-fun OkHttpClient.cancelGroup(group: Any?) {
-    group ?: return
-    dispatcher.runningCalls().forEach {
-        if (group === it.request().tagOf<NetTag.RequestGroup>()?.value) {
-            it.cancel()
-        }
-    }
-    dispatcher.queuedCalls().forEach {
-        if (group === it.request().tagOf<NetTag.RequestGroup>()?.value) {
-            it.cancel()
-        }
-    }
-}
+}