网球请求节流

This commit is contained in:
yangyakun
2025-04-01 14:44:43 +08:00
parent ec17b6d633
commit ec36a966f5
2 changed files with 9 additions and 1 deletions

View File

@@ -16,11 +16,14 @@ import static com.mogo.cloud.passport.MoGoAiCloudClient.TAG;
import static com.mogo.cloud.passport.MoGoAiCloudClientConfig.HTTP_DNS_ENV_DEV; import static com.mogo.cloud.passport.MoGoAiCloudClientConfig.HTTP_DNS_ENV_DEV;
import static com.mogo.cloud.passport.MoGoAiCloudClientConfig.HTTP_DNS_ENV_QA; import static com.mogo.cloud.passport.MoGoAiCloudClientConfig.HTTP_DNS_ENV_QA;
import java.util.concurrent.atomic.AtomicBoolean;
public class ThirdPassportManager { public class ThirdPassportManager {
private static volatile ThirdPassportManager mInstance; private static volatile ThirdPassportManager mInstance;
private IPassport mPassport; private IPassport mPassport;
private AtomicBoolean isRequestIng = new AtomicBoolean(false);
private ThirdPassportManager() { private ThirdPassportManager() {
} }
@@ -37,9 +40,13 @@ public class ThirdPassportManager {
} }
public void refreshToken(Context context, IPassport passport) { public void refreshToken(Context context, IPassport passport) {
if(isRequestIng.get()){
return;
}
this.mPassport = passport; this.mPassport = passport;
MoGoAiCloudClientConfig mAiCloudClientConfig = MoGoAiCloudClient.getInstance().getAiCloudClientConfig(); MoGoAiCloudClientConfig mAiCloudClientConfig = MoGoAiCloudClient.getInstance().getAiCloudClientConfig();
if (mAiCloudClientConfig != null) { if (mAiCloudClientConfig != null) {
isRequestIng.set(true);
ThirdLoginParam thirdLoginParam = ThirdLoginParam.of( ThirdLoginParam thirdLoginParam = ThirdLoginParam.of(
mAiCloudClientConfig.getThirdPartyDeviceId(), mAiCloudClientConfig.getThirdPartyDeviceId(),
mAiCloudClientConfig.getThirdPartyAppKey() mAiCloudClientConfig.getThirdPartyAppKey()
@@ -48,6 +55,7 @@ public class ThirdPassportManager {
LoginCallback loginCallback = new LoginCallback() { LoginCallback loginCallback = new LoginCallback() {
@Override @Override
public void onSuccess(TokenData.TokenResult result) { public void onSuccess(TokenData.TokenResult result) {
isRequestIng.set(false);
if (mPassport != null) { if (mPassport != null) {
mPassport.onSuccess(result.token, result.sn); mPassport.onSuccess(result.token, result.sn);
} }

View File

@@ -40,7 +40,7 @@ MOGO_UTILS_VERSION=1.4.7.62
# 网络请求 # 网络请求
MOGO_NETWORK_VERSION=1.4.7.62 MOGO_NETWORK_VERSION=1.4.7.62
# 鉴权 # 鉴权
MOGO_PASSPORT_VERSION=1.4.7.62 MOGO_PASSPORT_VERSION=1.4.7.63
# 常链接 # 常链接
MOGO_SOCKET_VERSION=1.4.7.62 MOGO_SOCKET_VERSION=1.4.7.62
# 数据采集 # 数据采集