From d8c0db1f8a2d091b0d5f1142c6703fa7cc4bbbf7 Mon Sep 17 00:00:00 2001 From: donghongyu Date: Wed, 29 Dec 2021 17:20:59 +0800 Subject: [PATCH] =?UTF-8?q?[Change]=20=E5=A2=9E=E5=8A=A0=E4=BA=86=E5=AF=B9?= =?UTF-8?q?=E5=AE=9A=E4=BD=8D=E4=B8=8A=E6=8A=A5=E5=8F=8ASocket=E7=9A=84?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E8=BE=93=E5=87=BA=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- foudations/mogo-socket/build.gradle | 3 -- .../socket/third/ThirdSocketManager.java | 3 +- .../core/client/ClientSocketManager.java | 4 +- .../cloud/socket/third/utils/RequestUtil.java | 37 ++++++++++++++----- gradle.properties | 20 +++++----- 5 files changed, 41 insertions(+), 26 deletions(-) diff --git a/foudations/mogo-socket/build.gradle b/foudations/mogo-socket/build.gradle index 2bd9ce5..61254fc 100644 --- a/foudations/mogo-socket/build.gradle +++ b/foudations/mogo-socket/build.gradle @@ -36,9 +36,6 @@ dependencies { // socket-for-internal 长链 内部SDK版本 implementation 'com.zhidao.socketsdk:socketsdk:2.1.4' - // 上报位置 http://wiki.zhidaohulian.com/pages/viewpage.action?pageId=48956200 - implementation 'com.zhidao.locupload:loc-upload-sdk:1.2.0' - if (Boolean.valueOf(RELEASE)) { implementation "com.mogo.cloud:passport:${MOGO_PASSPORT_VERSION}" diff --git a/foudations/mogo-socket/src/main/java/com/mogo/cloud/socket/third/ThirdSocketManager.java b/foudations/mogo-socket/src/main/java/com/mogo/cloud/socket/third/ThirdSocketManager.java index eac9611..9e2cb2d 100644 --- a/foudations/mogo-socket/src/main/java/com/mogo/cloud/socket/third/ThirdSocketManager.java +++ b/foudations/mogo-socket/src/main/java/com/mogo/cloud/socket/third/ThirdSocketManager.java @@ -19,7 +19,6 @@ import com.mogo.cloud.socket.third.core.CallbackManager; import com.mogo.cloud.socket.third.core.ConnectionLifecycleListener; import com.mogo.cloud.socket.third.core.SocketClient; import com.mogo.cloud.socket.third.core.SocketConfig; -import com.zhidao.locupload.Platform; import com.zhidao.ptech.connsvr.commom.protocol.MogoCommon; public class ThirdSocketManager implements Callback { @@ -47,7 +46,7 @@ public class ThirdSocketManager implements Callback { SocketConfig.instance() .setAppContext(context.getApplicationContext()) .setEnvironment(getEnvironment()) - .setClient(Platform.getClient(Platform.car)) + .setClient(MogoCommon.Client.car) .setChannelId(SocketServicesConstants.SOCKET_CHANNEL_ID) .setOpenAnalytics(true) .setSn(cloudClientConfig.getSn()) diff --git a/foudations/mogo-socket/src/main/java/com/mogo/cloud/socket/third/core/client/ClientSocketManager.java b/foudations/mogo-socket/src/main/java/com/mogo/cloud/socket/third/core/client/ClientSocketManager.java index 3e1e66f..cbdc7d8 100644 --- a/foudations/mogo-socket/src/main/java/com/mogo/cloud/socket/third/core/client/ClientSocketManager.java +++ b/foudations/mogo-socket/src/main/java/com/mogo/cloud/socket/third/core/client/ClientSocketManager.java @@ -166,8 +166,8 @@ public class ClientSocketManager { } onConnectSuccess(future1.channel()); } else { - Logger.i(SocketConstants.TAG, "Client---connecting server fails,失败重试"); - Logger.i(SocketConstants.TAG, future1.cause().getMessage()); + Logger.e(SocketConstants.TAG, "Client---connecting server fails,失败重试"); + Logger.e(SocketConstants.TAG, future1.cause().getMessage()); onConnectFailure(); } }); diff --git a/foudations/mogo-socket/src/main/java/com/mogo/cloud/socket/third/utils/RequestUtil.java b/foudations/mogo-socket/src/main/java/com/mogo/cloud/socket/third/utils/RequestUtil.java index 8c1db33..23578f2 100644 --- a/foudations/mogo-socket/src/main/java/com/mogo/cloud/socket/third/utils/RequestUtil.java +++ b/foudations/mogo-socket/src/main/java/com/mogo/cloud/socket/third/utils/RequestUtil.java @@ -5,6 +5,7 @@ import android.text.TextUtils; import com.elegant.log.simplelog.Logger; import com.mogo.cloud.passport.utils.DevicesUtils; +import com.mogo.cloud.socket.SocketBuildConfig; import com.mogo.cloud.socket.third.core.SocketConfig; import com.mogo.cloud.socket.third.core.SocketConstants; import com.mogo.cloud.socket.third.core.client.ClientSocketManager; @@ -23,23 +24,31 @@ public final class RequestUtil { } private static boolean checkNotNull(Channel channel) { - Logger.i(SocketConstants.TAG, channel == null ? "checkNotNull(channel), channel is null." : "checkNotNull(channel), channel is not null."); + if (SocketBuildConfig.isPrintLog) { + Logger.i(SocketConstants.TAG, channel == null ? "checkNotNull(channel), channel is null." : "checkNotNull(channel), channel is not null."); + } boolean isLogin = LoginStatusUtil.isLogin() && ClientSocketManager.getInstance().isConnected(); - Logger.i(SocketConstants.TAG, "socket connected is :" + isLogin); + if (SocketBuildConfig.isPrintLog) { + Logger.i(SocketConstants.TAG, "socket connected is :" + isLogin); + } return channel != null; } public static void login(Channel channel) { if (checkNotNull(channel)) { channel.writeAndFlush(RequestModelUtil.buildAuthRequest()); - Logger.i(SocketConstants.TAG, "requestAuth"); + if (SocketBuildConfig.isPrintLog) { + Logger.i(SocketConstants.TAG, "requestAuth"); + } } } public static void ack(Channel channel, byte[] data) { if (checkNotNull(channel)) { channel.writeAndFlush(data); - Logger.i(SocketConstants.TAG, "ack"); + if (SocketBuildConfig.isPrintLog) { + Logger.i(SocketConstants.TAG, "ack"); + } } } @@ -47,21 +56,27 @@ public final class RequestUtil { Channel channel = ClientSocketManager.getInstance().getChannel(); if (checkNotNull(channel)) { channel.writeAndFlush(RequestModelUtil.buildEncodeInfo(key)); - Logger.i(SocketConstants.TAG, "checkAuth"); + if (SocketBuildConfig.isPrintLog) { + Logger.i(SocketConstants.TAG, "checkAuth"); + } } } public static void sendHeartbeat(Channel channel) { if (checkNotNull(channel)) { channel.writeAndFlush(RequestModelUtil.buildHeartbeat()); - Logger.i(SocketConstants.TAG, "send heartbeat"); + if (SocketBuildConfig.isPrintLog) { + Logger.i(SocketConstants.TAG, "send heartbeat"); + } } } public static void sendUserInfo(Channel channel) { if (checkNotNull(channel)) { channel.writeAndFlush(RequestModelUtil.buildUserInfo()); - Logger.i(SocketConstants.TAG, "send user info"); + if (SocketBuildConfig.isPrintLog) { + Logger.i(SocketConstants.TAG, "send user info"); + } } } @@ -72,7 +87,9 @@ public final class RequestUtil { final Channel channel = ClientSocketManager.getInstance().getChannel(); if (checkNotNull(channel)) { channel.writeAndFlush(RequestModelUtil.buildPayloadData(productLine, appId, payload, headerType, ack, msgId)); - Logger.i(SocketConstants.TAG, "send---> appId is: " + appId + "; headerType is: " + headerType+ "; msgId is: " + msgId); + if (SocketBuildConfig.isPrintLog) { + Logger.i(SocketConstants.TAG, "send---> appId is: " + appId + "; headerType is: " + headerType + "; msgId is: " + msgId); + } } } @@ -104,7 +121,9 @@ public final class RequestUtil { if (TextUtils.isEmpty(appId)) { appId = "unknown"; } - Logger.i(SocketConstants.TAG, "socket app id is " + appId + ", msg type is " + msgType); + if (SocketBuildConfig.isPrintLog) { + Logger.i(SocketConstants.TAG, "socket app id is " + appId + ", msg type is " + msgType); + } return buildHeader(appId, 0, msgType, false, 0); } diff --git a/gradle.properties b/gradle.properties index cf67562..c0321a7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -36,22 +36,22 @@ PASSWORD=xintai2018 RELEASE=true # AI CLOUD 云平台 # 工具类 -MOGO_UTILS_VERSION=1.3.14 +MOGO_UTILS_VERSION=1.3.15 # 网络请求 -MOGO_NETWORK_VERSION=1.3.14 +MOGO_NETWORK_VERSION=1.3.15 # 网络DNS -MOGO_HTTPDNS_VERSION=1.3.14 +MOGO_HTTPDNS_VERSION=1.3.15 # 鉴权 -MOGO_PASSPORT_VERSION=1.3.14 +MOGO_PASSPORT_VERSION=1.3.15 # 常链接 -MOGO_SOCKET_VERSION=1.3.14 +MOGO_SOCKET_VERSION=1.3.15 # 数据采集 -MOGO_REALTIME_VERSION=1.3.14 +MOGO_REALTIME_VERSION=1.3.15 # 探路,道路事件发布,获取 -MOGO_TANLU_VERSION=1.3.14 +MOGO_TANLU_VERSION=1.3.15 # 直播推流 -MOGO_LIVE_VERSION=1.3.14 +MOGO_LIVE_VERSION=1.3.15 # 直播拉流 -MOGO_TRAFFICLIVE_VERSION=1.3.14 +MOGO_TRAFFICLIVE_VERSION=1.3.15 # 定位服务 -MOGO_LOCATION_VERSION=1.3.14 +MOGO_LOCATION_VERSION=1.3.15