[master]expand the interface of socket, add sn

This commit is contained in:
zhongchao
2023-05-17 19:38:18 +08:00
parent 6a5e560f2a
commit b0446402be
7 changed files with 28 additions and 24 deletions

View File

@@ -16,7 +16,7 @@ public interface IMogoCloudSocketManager {
*
* @param context 上下文
*/
void init(Context context, double lat, double lon);
void init(Context context, String sn, double lat, double lon);
/**
* 重新连接

View File

@@ -75,9 +75,9 @@ public class SocketManager implements IMogoCloudSocketManager {
private int mCurrentIndex = 0;
@Override
public void init(Context context, double lat, double lon) {
public void init(Context context, String sn, double lat, double lon) {
if (cloudClientConfig.isThirdLogin()) {
ThirdSocketManager.getInstance().init(context, lat, lon);
ThirdSocketManager.getInstance().init(context, sn, lat, lon);
} else {
InternalSocketManager.getInstance().init(context);
}

View File

@@ -45,18 +45,22 @@ public class ThirdSocketManager implements Callback, ErrorCallback {
return mInstance;
}
public void init(Context context, double lat, double lon) {
public void init(Context context, String sn, double lat, double lon) {
MLocation mLocation = new MLocation();
mLocation.setCoordinate(GCJ02);
mLocation.setLatitude(lat);
mLocation.setLongitude(lon);
String tempSn = cloudClientConfig.getSn();
if (tempSn == null || tempSn.isEmpty()) {
tempSn = sn;
}
SocketConfig.instance()
.setAppContext(context.getApplicationContext())
.setEnvironment(getEnvironment())
.setClient(MogoCommon.Client.car)
.setChannelId(SocketServicesConstants.SOCKET_CHANNEL_ID)
.setOpenAnalytics(true)
.setSn(cloudClientConfig.getSn())
.setSn(tempSn)
.setToken(cloudClientConfig.getToken())
.setSecretKey(cloudClientConfig.getSecretKey())
.setAuthPubKey(cloudClientConfig.getAuthPubKey())
@@ -69,7 +73,7 @@ public class ThirdSocketManager implements Callback, ErrorCallback {
SocketClient.getInstance().start(context);
}
public void reConnect(){
public void reConnect() {
SocketClient.getInstance().stopAndRestart();
}