[Change] 增加了对定位上报及Socket的日志输出控制
This commit is contained in:
@@ -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())
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user