[6.2.4][Feat]新增QUIC请求延时回调和协议开关
This commit is contained in:
@@ -407,4 +407,8 @@ class DevaToolsProvider : IDevaToolsProvider {
|
||||
override fun block(): IMoGoBlockProvider? = block
|
||||
|
||||
override fun usage(): IMoGoCpuUsageProvider? = usage
|
||||
|
||||
override fun setNetworkMode(isDebug: Boolean) {
|
||||
WeakNetworkStrategy.setDebug(isDebug)
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ object WeakNetworkStrategy {
|
||||
private const val TAG = "WeakNetworkStrategy"
|
||||
|
||||
// 记录到链路日志中的时间间隔
|
||||
private const val OUTPUT_TIME_INTERVAL = 15000
|
||||
private const val OUTPUT_TIME_INTERVAL = 2500
|
||||
|
||||
private const val WEAK_HTTP_RTT = 1300
|
||||
|
||||
@@ -23,6 +23,8 @@ object WeakNetworkStrategy {
|
||||
|
||||
private var lastOutputTime = 0L
|
||||
|
||||
private var isDebug = false
|
||||
|
||||
private val lock by lazy {
|
||||
ReentrantReadWriteLock()
|
||||
}
|
||||
@@ -53,6 +55,10 @@ object WeakNetworkStrategy {
|
||||
})
|
||||
}
|
||||
|
||||
fun setDebug(isDebug: Boolean) {
|
||||
this.isDebug = isDebug
|
||||
}
|
||||
|
||||
fun stopListen() {
|
||||
setListener(null)
|
||||
}
|
||||
@@ -63,10 +69,13 @@ object WeakNetworkStrategy {
|
||||
try {
|
||||
val currentTime = System.currentTimeMillis()
|
||||
if (currentTime - lastOutputTime > OUTPUT_TIME_INTERVAL) {
|
||||
if (isDebug) {
|
||||
invokeWeakResult("url为:$url, 耗时为:$timeStamp${if (isFail) " 连接失败!" else ""}")
|
||||
}
|
||||
if (timeStamp >= WEAK_HTTP_RTT) {
|
||||
ToastUtils.showShort("当前网络质量差!")
|
||||
} else if (timeStamp in 300 until WEAK_HTTP_RTT) {
|
||||
invokeWeakResult("url为:$url, 耗时为:$timeStamp${if (isFail) " 连接失败!" else ""}")
|
||||
// invokeWeakResult("url为:$url, 耗时为:$timeStamp${if (isFail) " 连接失败!" else ""}")
|
||||
SdtManager.startActiveCheck()
|
||||
}
|
||||
lastOutputTime = currentTime
|
||||
|
||||
Reference in New Issue
Block a user