fix bug of init httpdnsclient

This commit is contained in:
zhongchao
2023-06-01 14:12:29 +08:00
parent 57517a1a16
commit 1bd1be4c39
2 changed files with 21 additions and 20 deletions

View File

@@ -14,7 +14,6 @@ import com.google.protobuf.ByteString;
import com.google.protobuf.InvalidProtocolBufferException;
import com.google.protobuf.MessageLiteOrBuilder;
import com.mogo.cloud.passport.MoGoAiCloudClient;
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
import com.mogo.cloud.socket.entity.MsgBody;
import com.mogo.cloud.socket.internal.InternalSocketManager;
import com.mogo.cloud.socket.third.ThirdSocketManager;
@@ -34,13 +33,10 @@ import java.util.concurrent.ConcurrentHashMap;
*/
public class SocketManager implements IMogoCloudSocketManager {
private static volatile SocketManager mInstance;
private MoGoAiCloudClientConfig cloudClientConfig;
private static final String TAG = "SocketManager";
private static volatile SocketManager mInstance;
private SocketManager() {
cloudClientConfig = MoGoAiCloudClient.getInstance().getAiCloudClientConfig();
}
public static SocketManager getInstance() {
@@ -76,7 +72,7 @@ public class SocketManager implements IMogoCloudSocketManager {
@Override
public void init(Context context, String sn, double lat, double lon) {
if (cloudClientConfig.isThirdLogin()) {
if (check()) {
ThirdSocketManager.getInstance().init(context, sn, lat, lon);
} else {
InternalSocketManager.getInstance().init(context);
@@ -85,7 +81,7 @@ public class SocketManager implements IMogoCloudSocketManager {
@Override
public void reConnect() {
if (cloudClientConfig.isThirdLogin()) {
if (check()) {
ThirdSocketManager.getInstance().reConnect();
}
}
@@ -163,7 +159,7 @@ public class SocketManager implements IMogoCloudSocketManager {
}
final byte[] pb = convertToPBBytes(body.getMsgType(), body.getContent());
if (cloudClientConfig.isThirdLogin()) {
if (check()) {
ThirdSocketManager.getInstance().sendMsg(appId, pb, headerType, true, body.getMsgId());
} else {
InternalSocketManager.getInstance().sendMsg(pb, headerType, true, body.getMsgId());
@@ -275,11 +271,16 @@ public class SocketManager implements IMogoCloudSocketManager {
}
public synchronized void release() {
if (cloudClientConfig.isThirdLogin()) {
if (check()) {
ThirdSocketManager.getInstance().release();
} else {
InternalSocketManager.getInstance().release();
}
}
private boolean check(){
return (MoGoAiCloudClient.getInstance().getAiCloudClientConfig()!= null
&& MoGoAiCloudClient.getInstance().getAiCloudClientConfig().isThirdLogin());
}
}