@@ -1 +0,0 @@
|
||||
/build
|
||||
@@ -1,46 +0,0 @@
|
||||
apply plugin: 'com.android.library'
|
||||
|
||||
android {
|
||||
compileSdkVersion rootProject.ext.android.compileSdkVersion
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion rootProject.ext.android.minSdkVersion
|
||||
targetSdkVersion rootProject.ext.android.targetSdkVersion
|
||||
versionCode Integer.valueOf(VERSION_CODE)
|
||||
versionName getValueFromRootProperties("${project.name.replace("-", "_").toUpperCase()}_VERSION")
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
consumerProguardFiles "consumer-rules.pro"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: "libs", include: ["*.jar"])
|
||||
implementation rootProject.ext.dependencies.arouter
|
||||
implementation rootProject.ext.dependencies.mogowebsocket
|
||||
|
||||
if (Boolean.valueOf(USE_MAVEN_PACKAGE)) {
|
||||
implementation rootProject.ext.dependencies.mogo_core_utils
|
||||
implementation rootProject.ext.dependencies.mogocommons
|
||||
implementation rootProject.ext.dependencies.mogoserviceapi
|
||||
} else {
|
||||
implementation project(':core:mogo-core-utils')
|
||||
implementation project(":foudations:mogo-commons")
|
||||
implementation project(":services:mogo-service-api")
|
||||
implementation project(':modules:mogo-module-common')
|
||||
}
|
||||
}
|
||||
|
||||
apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()
|
||||
@@ -1,3 +0,0 @@
|
||||
-keep class com.mogo.base.websocket.WebSocketData{*;}
|
||||
-keep class com.mogo.base.websocket.WebSocketShakeHandsData{*;}
|
||||
-keep class com.mogo.base.websocket.WebSocketManager{*;}
|
||||
@@ -1,3 +0,0 @@
|
||||
GROUP=com.mogo.base
|
||||
POM_ARTIFACT_ID=websocket-sdk
|
||||
VERSION_CODE=1
|
||||
@@ -1,21 +0,0 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
@@ -1,5 +0,0 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.mogo.base.websocket">
|
||||
|
||||
/
|
||||
</manifest>
|
||||
@@ -1,6 +0,0 @@
|
||||
package com.mogo.base.websocket;
|
||||
|
||||
public interface IMogoWebSocketInitCallBack {
|
||||
|
||||
void init();
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
package com.mogo.base.websocket;
|
||||
|
||||
|
||||
import androidx.annotation.Keep;
|
||||
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
|
||||
@Keep
|
||||
public class WebSocketConstant {
|
||||
|
||||
private static final String HOST_DEV = "ws://119.45.249.167";
|
||||
private static final String HOST_QA = "ws://119.45.249.167";
|
||||
private static final String HOST_DEMO = "ws://119.45.249.167";
|
||||
@Keep
|
||||
private static final String HOST_RELEASE = "ws://119.45.249.167";
|
||||
// private static final String PORT = ":14001/ws";
|
||||
@Keep
|
||||
public static final String PATH = "/ws";
|
||||
@Keep
|
||||
public static final String PORT = ":4004"+PATH;
|
||||
@Keep
|
||||
public static final String PROTOCOL = "ws://";
|
||||
|
||||
public static String getSocketServer() {
|
||||
switch (DebugConfig.getNetMode()) {
|
||||
case DebugConfig.NET_MODE_DEV:
|
||||
return HOST_DEV;
|
||||
case DebugConfig.NET_MODE_QA:
|
||||
return HOST_QA;
|
||||
case DebugConfig.NET_MODE_DEMO:
|
||||
return HOST_DEMO;
|
||||
case DebugConfig.NET_MODE_RELEASE:
|
||||
default:
|
||||
return HOST_RELEASE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// public static String getSocketPort() {
|
||||
// return PORT;
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
package com.mogo.base.websocket;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class WebSocketData implements Serializable {
|
||||
|
||||
private long seq;
|
||||
|
||||
private int msgType;
|
||||
|
||||
private String sn;
|
||||
|
||||
private String data;
|
||||
|
||||
private long utcTime;
|
||||
|
||||
private long upUtcTime;
|
||||
|
||||
private String cityCode;
|
||||
|
||||
public long getSeq() {
|
||||
return seq;
|
||||
}
|
||||
|
||||
public void setSeq(long seq) {
|
||||
this.seq = seq;
|
||||
}
|
||||
|
||||
public int getMsgType() {
|
||||
return msgType;
|
||||
}
|
||||
|
||||
public void setMsgType(int msgType) {
|
||||
this.msgType = msgType;
|
||||
}
|
||||
|
||||
public String getSn() {
|
||||
return sn;
|
||||
}
|
||||
|
||||
public void setSn(String sn) {
|
||||
this.sn = sn;
|
||||
}
|
||||
|
||||
public String getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(String data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public long getUtcTime() {
|
||||
return utcTime;
|
||||
}
|
||||
|
||||
public void setUtcTime(long utcTime) {
|
||||
this.utcTime = utcTime;
|
||||
}
|
||||
|
||||
public long getUpUtcTime() {
|
||||
return upUtcTime;
|
||||
}
|
||||
|
||||
public void setUpUtcTime(long upUtcTime) {
|
||||
this.upUtcTime = upUtcTime;
|
||||
}
|
||||
|
||||
public String getCityCode() {
|
||||
return cityCode;
|
||||
}
|
||||
|
||||
public void setCityCode(String cityCode) {
|
||||
this.cityCode = cityCode;
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
package com.mogo.base.websocket;
|
||||
|
||||
|
||||
import com.mogo.httpdns.HttpDnsConst;
|
||||
import com.mogo.httpdns.IMogoHttpDns;
|
||||
import com.mogo.httpdns.MogoHttpDnsHandler;
|
||||
import com.mogo.module.common.constants.HostConst;
|
||||
import com.mogo.utils.ThreadPoolService;
|
||||
|
||||
|
||||
public class WebSocketDnsManager {
|
||||
|
||||
private static final String TAG = "WebSocketDnsManager";
|
||||
|
||||
private WebSocketDnsManager() {
|
||||
|
||||
}
|
||||
|
||||
private static final class Holder {
|
||||
private static final WebSocketDnsManager dnsManager = new WebSocketDnsManager();
|
||||
}
|
||||
|
||||
public static WebSocketDnsManager getInstance() {
|
||||
return Holder.dnsManager;
|
||||
}
|
||||
|
||||
private WebSocketDns webSocketDns;
|
||||
private String cacheIp;
|
||||
|
||||
public void getHttpDnsIp(WebSocketDns webSocketDns) {
|
||||
this.webSocketDns = webSocketDns;
|
||||
IMogoHttpDns mogoHttpDns = MogoHttpDnsHandler.getHttpDnsApi();
|
||||
ThreadPoolService.execute(() -> mogoHttpDns.getHttpDnsIp(HostConst.WEBSOCKET_DOMAIN, HttpDnsConst.HTTP_DNS_ADDRESS_TYPE_WS, false, ip -> {
|
||||
Logger.d(TAG, "getHttpDnsIp ip : " + ip + " , 得到Dns IP,准备回调 初始化webSocket");
|
||||
this.cacheIp = ip;
|
||||
this.webSocketDns.getDnsIp((cacheIp != null ?
|
||||
WebSocketConstant.PROTOCOL + ip + WebSocketConstant.PATH :
|
||||
WebSocketConstant.getSocketServer() + WebSocketConstant.PORT));
|
||||
}));
|
||||
mogoHttpDns.addressChangedListener(map -> {
|
||||
Logger.d(TAG, "ttl callBack ,ready to getCache Dns IP");
|
||||
String dnsCacheIp = mogoHttpDns.getCachedHttpDnsIps(HostConst.WEBSOCKET_DOMAIN, HttpDnsConst.HTTP_DNS_ADDRESS_TYPE_WS);
|
||||
if (dnsCacheIp == null) {
|
||||
return;
|
||||
}
|
||||
Logger.d(TAG, "获取缓存Dns IP : " + dnsCacheIp + " , 原缓存 IP : " + cacheIp);
|
||||
if (cacheIp != null && !cacheIp.equals(dnsCacheIp)) {
|
||||
this.webSocketDns.ttlIp(dnsCacheIp + WebSocketConstant.PATH);
|
||||
this.cacheIp = dnsCacheIp;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public interface WebSocketDns {
|
||||
|
||||
void getDnsIp(String url);
|
||||
|
||||
void ttlIp(String url);
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
package com.mogo.base.websocket;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.os.HandlerThread;
|
||||
import android.os.Message;
|
||||
|
||||
import com.mogo.websocket.SocketClient;
|
||||
|
||||
public class WebSocketHandlerThread extends HandlerThread {
|
||||
|
||||
private Handler mHandler;
|
||||
private String tag;
|
||||
|
||||
private static final int MSG_SEND = 1;
|
||||
|
||||
public WebSocketHandlerThread(String name) {
|
||||
super(name);
|
||||
tag = name;
|
||||
}
|
||||
|
||||
|
||||
public void initHandler(){
|
||||
mHandler = new Handler(this.getLooper()) {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
super.handleMessage(msg);
|
||||
if (msg.what == MSG_SEND) {
|
||||
Logger.d(tag, "WebSocketHandlerThread handleMessage = " + msg.obj.toString());
|
||||
WebSocketInstanceHolder.getClientProxy().sendMessage(msg.obj.toString());
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public void sendMsg(String msg) {
|
||||
if(mHandler!=null) {
|
||||
Message message = new Message();
|
||||
message.what = MSG_SEND;
|
||||
message.obj = msg;
|
||||
mHandler.sendMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package com.mogo.base.websocket;
|
||||
|
||||
import com.mogo.websocket.SocketClient;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/12/24
|
||||
*
|
||||
* 描述
|
||||
*/
|
||||
class WebSocketInstanceHolder {
|
||||
|
||||
private volatile static SocketClient sClient;
|
||||
|
||||
public static SocketClient getClientProxy() {
|
||||
if ( sClient == null ) {
|
||||
synchronized ( WebSocketInstanceHolder.class ) {
|
||||
if ( sClient == null ) {
|
||||
sClient = new SocketClient();
|
||||
}
|
||||
}
|
||||
}
|
||||
return sClient;
|
||||
}
|
||||
}
|
||||
@@ -1,253 +0,0 @@
|
||||
package com.mogo.base.websocket;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.SystemClock;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.Keep;
|
||||
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
|
||||
import com.mogo.commons.network.Utils;
|
||||
import com.mogo.map.location.MogoLocation;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.service.connection.IMogoMsgAckListener;
|
||||
import com.mogo.service.connection.IMogoOnWebSocketMessageListener;
|
||||
import com.mogo.service.connection.IMogoWebSocketManager;
|
||||
import com.mogo.utils.network.utils.GsonUtil;
|
||||
import com.mogo.websocket.ISocketMsgCallBack;
|
||||
import com.mogo.websocket.ISocketMsgSetting;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import static com.mogo.service.connection.WebSocketMsgType.MSG_TYPE_ACK;
|
||||
import static com.mogo.service.connection.WebSocketMsgType.MSG_TYPE_DOWNLINK_CAR_DATA;
|
||||
|
||||
public class WebSocketManager implements IMogoWebSocketManager, ISocketMsgSetting,
|
||||
ISocketMsgCallBack {
|
||||
|
||||
private static final String TAG = "WebSocketManager-sdk";
|
||||
|
||||
private static volatile WebSocketManager sInstance;
|
||||
private WebSocketHandlerThread handlerThread;
|
||||
|
||||
public WebSocketManager(Context context) {
|
||||
handlerThread = new WebSocketHandlerThread(TAG);
|
||||
handlerThread.start();
|
||||
handlerThread.initHandler();
|
||||
}
|
||||
|
||||
@Keep
|
||||
public static WebSocketManager getInstance(Context context) {
|
||||
if (sInstance == null) {
|
||||
synchronized (WebSocketManager.class) {
|
||||
if (sInstance == null) {
|
||||
sInstance = new WebSocketManager(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
/**
|
||||
* 管理消息分发
|
||||
* <p>
|
||||
* key - msgType
|
||||
*/
|
||||
private Map<Integer, List<IMogoOnWebSocketMessageListener>> mListeners =
|
||||
new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* 管理消息回执
|
||||
* <p>
|
||||
* key - msgId
|
||||
*/
|
||||
private Map<Long, IMogoMsgAckListener> mAckListeners = new ConcurrentHashMap<>();
|
||||
|
||||
@Override
|
||||
public void init(Context context, String appId) {
|
||||
WebSocketDnsManager.getInstance().getHttpDnsIp(new WebSocketDnsManager.WebSocketDns() {
|
||||
@Override
|
||||
public void getDnsIp(String url) {
|
||||
Logger.d(TAG,"getDnsIp url : " + url);
|
||||
initWebSocket(url);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ttlIp(String url) {
|
||||
Logger.d(TAG,"ttlIp url : " + url);
|
||||
if(!WebSocketInstanceHolder.getClientProxy().isOpen()){
|
||||
return;
|
||||
}
|
||||
WebSocketInstanceHolder.getClientProxy().stop();
|
||||
WebSocketInstanceHolder.getClientProxy().disConnect();
|
||||
Logger.d(TAG,"ready to re initWebSocket : " + url);
|
||||
initWebSocket(url);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initWebSocket(String ip){
|
||||
WebSocketInstanceHolder.getClientProxy().initSocketServer(ip);
|
||||
WebSocketInstanceHolder.getClientProxy().getMessageSettings(this);
|
||||
WebSocketInstanceHolder.getClientProxy().addISocketMsgCallBack(this);
|
||||
WebSocketInstanceHolder.getClientProxy().startConnect();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerOnWebSocketMessageListener(IMogoOnWebSocketMessageListener listener) {
|
||||
if (listener.getDownLinkType() == null) {
|
||||
Logger.w(TAG, "websocket registerListener msgType is not exist");
|
||||
return;
|
||||
}
|
||||
int msgType = listener.getDownLinkType().getMsgType();
|
||||
|
||||
if (!mListeners.containsKey(msgType)) {
|
||||
mListeners.put(msgType, new ArrayList<>());
|
||||
}
|
||||
mListeners.get(msgType).add(listener);
|
||||
Logger.d(TAG, "websocket add listener success");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterOnWebSocketMessageListener(IMogoOnWebSocketMessageListener listener) {
|
||||
if (listener == null) {
|
||||
return;
|
||||
}
|
||||
if (listener.getDownLinkType() == null) {
|
||||
Logger.w(TAG, "websocket unregisterListener msgType is not exist");
|
||||
return;
|
||||
}
|
||||
int msgType = listener.getDownLinkType().getMsgType();
|
||||
if (!mListeners.containsKey(msgType)) {
|
||||
return;
|
||||
}
|
||||
List<IMogoOnWebSocketMessageListener> listeners = mListeners.get(msgType);
|
||||
if (listeners != null && listeners.contains(listener)) {
|
||||
listeners.remove(listener);
|
||||
Logger.d(TAG, "websocket remove listener success");
|
||||
}
|
||||
}
|
||||
private long timeRecord = 0;
|
||||
@Override
|
||||
public void sendMsg(Object body, IMogoOnWebSocketMessageListener listener) {
|
||||
Logger.d(TAG, "websocket sendMsg body = " + body);
|
||||
if (handlerThread != null) {
|
||||
WebSocketData webSocketData = new WebSocketData();
|
||||
webSocketData.setSeq(computeSendMsgTime());
|
||||
webSocketData.setMsgType(listener.getUpLinkType().getMsgType());
|
||||
webSocketData.setSn(MoGoAiCloudClientConfig.getInstance().getSn());
|
||||
webSocketData.setData(GsonUtil.jsonFromObject(body));
|
||||
MogoLocation lastKnown = MogoApisHandler.getInstance().getApis().getMapServiceApi().getSingletonLocationClient(context).getLastKnowLocation();
|
||||
if (lastKnown != null&&!lastKnown.getCityCode().isEmpty()) {
|
||||
webSocketData.setCityCode(lastKnown.getCityCode());
|
||||
}else{
|
||||
webSocketData.setCityCode(null);
|
||||
}
|
||||
String msg = GsonUtil.jsonFromObject(webSocketData);
|
||||
Logger.d(TAG,"sendMsg : " + msg);
|
||||
timeRecord = System.currentTimeMillis();
|
||||
handlerThread.sendMsg(msg);
|
||||
}
|
||||
}
|
||||
|
||||
private Context context;
|
||||
@Override
|
||||
public void init(Context context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnectOpen() {
|
||||
Logger.d(TAG, "websocket onConnectOpen");
|
||||
}
|
||||
|
||||
private long serverTime = 0;
|
||||
private long receiveMsgTime = 0;
|
||||
|
||||
/**
|
||||
* 服务端会在ack数据中增加服务端的时间戳{@link #serverTime}, 收到消息时,记录收到消息的时间{@link #receiveMsgTime},收消息的时间用{@link SystemClock#elapsedRealtime()}可以避免系统时间改变造成的影响
|
||||
* 在发送数据时,使用serverTime+(elapseRealtime()-receiveMsgTime)计算发送数据时的时间戳,这个时间戳是基本相对服务端的时间戳为基准的时间,忽略了ack下发时的时间延迟
|
||||
*
|
||||
* 如果{@link #serverTime}或{@link #receiveMsgTime}数据有异常,则使用{@link System#currentTimeMillis()}当做当前时间,作为容错
|
||||
*
|
||||
* @return 基本相对服务端的时间戳为基准的时间
|
||||
*/
|
||||
private long computeSendMsgTime(){
|
||||
long sendMsgTime = 0;
|
||||
if (serverTime > 0 && receiveMsgTime > 0) {
|
||||
sendMsgTime = serverTime + (SystemClock.elapsedRealtime() - receiveMsgTime);
|
||||
}else{
|
||||
sendMsgTime = System.currentTimeMillis();
|
||||
}
|
||||
return sendMsgTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMessage(String message) {
|
||||
Logger.d(TAG, "websocket received msg = %s", message);
|
||||
WebSocketData webSocketData = GsonUtil.objectFromJson(message, WebSocketData.class);
|
||||
int msgType = webSocketData.getMsgType();
|
||||
Logger.d(TAG, "websocket received msg type = " + msgType);
|
||||
//服务端下发数据返回,上传数据回执默认不返回
|
||||
if (msgType == MSG_TYPE_DOWNLINK_CAR_DATA.getMsgType()) {
|
||||
List<IMogoOnWebSocketMessageListener> listeners = mListeners.get(msgType);
|
||||
if (listeners != null && !listeners.isEmpty()) {
|
||||
Iterator<IMogoOnWebSocketMessageListener> iterator = listeners.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
IMogoOnWebSocketMessageListener listener = iterator.next();
|
||||
if (listener != null) {
|
||||
Logger.d(TAG, "received msgId = %s, content = %s", webSocketData.getSeq(),webSocketData.getData());
|
||||
Object receiveObj = GsonUtil.objectFromJson(webSocketData.getData(),listener.target());
|
||||
final long start = System.currentTimeMillis();
|
||||
listener.onMsgReceived(receiveObj);
|
||||
Logger.d("WebSocketManager-sdk-timer", "cost " + (System.currentTimeMillis() - start) + "ms");
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (msgType == MSG_TYPE_ACK.getMsgType()) {
|
||||
long delta = System.currentTimeMillis() - timeRecord;
|
||||
Logger.d("TimeRecord", "send->ack: " + delta);
|
||||
if (webSocketData.getUtcTime() > 0) {
|
||||
serverTime = webSocketData.getUtcTime();
|
||||
receiveMsgTime = SystemClock.elapsedRealtime();
|
||||
Logger.d(TAG, "设置serverTime");
|
||||
if (webSocketData.getUpUtcTime() > 0) {
|
||||
long nextDelay = webSocketData.getUpUtcTime() - serverTime;
|
||||
MogoApisHandler.getInstance().getApis().getRefreshStrategyControllerApi().resetLocationUpDelay(nextDelay);
|
||||
Logger.d(TAG, "重置下次上报时机: " + nextDelay);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnectClose() {
|
||||
Logger.d(TAG, "websocket ready to reconnect");
|
||||
WebSocketInstanceHolder.getClientProxy().stop();
|
||||
WebSocketInstanceHolder.getClientProxy().reConnect();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleError(Exception e) {
|
||||
Logger.e(TAG, "websocket handleError : " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHandShakeMsg() {
|
||||
WebSocketShakeHandsData webSocketShakeHandData = new WebSocketShakeHandsData(
|
||||
System.currentTimeMillis(),
|
||||
MoGoAiCloudClientConfig.getInstance().getSn(),
|
||||
true
|
||||
);
|
||||
return GsonUtil.jsonFromObject(webSocketShakeHandData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHeartBeatMsg() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
package com.mogo.base.websocket;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class WebSocketShakeHandsData implements Serializable {
|
||||
|
||||
public WebSocketShakeHandsData(){
|
||||
|
||||
}
|
||||
|
||||
public WebSocketShakeHandsData(long seq, String sn, boolean bind) {
|
||||
this.seq = seq;
|
||||
this.sn = sn;
|
||||
this.bind = bind;
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求序列号
|
||||
*/
|
||||
private long seq;
|
||||
|
||||
/**
|
||||
* 车机sn
|
||||
*/
|
||||
private String sn;
|
||||
|
||||
/**
|
||||
* 是否申请通道绑定
|
||||
*/
|
||||
private boolean bind;
|
||||
|
||||
public long getSeq() {
|
||||
return seq;
|
||||
}
|
||||
|
||||
public void setSeq(long seq) {
|
||||
this.seq = seq;
|
||||
}
|
||||
|
||||
public String getSn() {
|
||||
return sn;
|
||||
}
|
||||
|
||||
public void setSn(String sn) {
|
||||
this.sn = sn;
|
||||
}
|
||||
|
||||
public boolean isBind() {
|
||||
return bind;
|
||||
}
|
||||
|
||||
public void setBind(boolean bind) {
|
||||
this.bind = bind;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user