|
|
|
|
@@ -37,7 +37,7 @@ import okhttp3.WebSocketListener;
|
|
|
|
|
import okio.ByteString;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @ProjectName: lib-adas-fpga
|
|
|
|
|
* @Package: com.zhidao.lib.adas.high
|
|
|
|
|
* @ClassName: FpgaSocket
|
|
|
|
|
* @Description: java类作用描述
|
|
|
|
|
@@ -49,6 +49,7 @@ import okio.ByteString;
|
|
|
|
|
* @Version: 1.0
|
|
|
|
|
*/
|
|
|
|
|
public class FpgaSocket implements IWebSocket {
|
|
|
|
|
private static final String TAG = FpgaSocket.class.getSimpleName();
|
|
|
|
|
private OkHttpClient client;
|
|
|
|
|
|
|
|
|
|
private WebSocket mWebSocket;
|
|
|
|
|
@@ -91,7 +92,7 @@ public class FpgaSocket implements IWebSocket {
|
|
|
|
|
@Override
|
|
|
|
|
public void connectWebSocket(String address) {
|
|
|
|
|
String wsHost = WS_IP_HOST_HEAD + address + WS_PORT;
|
|
|
|
|
CupidLogUtils.e("--->connectWebSocket" + wsHost);
|
|
|
|
|
CupidLogUtils.i(TAG, "--->connectWebSocket" + wsHost);
|
|
|
|
|
init();
|
|
|
|
|
if (client != null) {
|
|
|
|
|
request = new Request.Builder()
|
|
|
|
|
@@ -103,7 +104,7 @@ public class FpgaSocket implements IWebSocket {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void closeWebSocket() {
|
|
|
|
|
CupidLogUtils.e("===>closeWebSocket");
|
|
|
|
|
CupidLogUtils.i(TAG, "===>closeWebSocket");
|
|
|
|
|
if (AdasChannel.isUseQueue) {
|
|
|
|
|
WebSocketQueueManager.getInstance().release();
|
|
|
|
|
WSByteQueueManager.getInstance().release();
|
|
|
|
|
@@ -113,7 +114,7 @@ public class FpgaSocket implements IWebSocket {
|
|
|
|
|
jsonObject = null;
|
|
|
|
|
if (mWebSocket != null) {
|
|
|
|
|
boolean isClose = mWebSocket.close(1000, null);
|
|
|
|
|
CupidLogUtils.e("===>webSocket关闭了吗" + isClose);
|
|
|
|
|
CupidLogUtils.i(TAG, "===>webSocket关闭了吗" + isClose);
|
|
|
|
|
|
|
|
|
|
mWebSocket.cancel();
|
|
|
|
|
mWebSocket = null;
|
|
|
|
|
@@ -127,7 +128,7 @@ public class FpgaSocket implements IWebSocket {
|
|
|
|
|
public boolean sendDataWebSocket(String data) {
|
|
|
|
|
if (mWebSocket != null) {
|
|
|
|
|
boolean result = mWebSocket.send(data);
|
|
|
|
|
CupidLogUtils.e("FpgaSocket--->sendDataWebSocket--->String: " + data + ", result= " + result);
|
|
|
|
|
CupidLogUtils.i(TAG, "sendDataWebSocket--->String: " + data + ", result= " + result);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
@@ -137,7 +138,7 @@ public class FpgaSocket implements IWebSocket {
|
|
|
|
|
public boolean sendDataWebSocket(ByteString data) {
|
|
|
|
|
if (mWebSocket != null) {
|
|
|
|
|
boolean result = mWebSocket.send(data);
|
|
|
|
|
CupidLogUtils.e("FpgaSocket--->sendDataWebSocket--->ByteString: " + data + ", result= " + result);
|
|
|
|
|
CupidLogUtils.i(TAG, "sendDataWebSocket--->ByteString: " + data + ", result= " + result);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
@@ -145,17 +146,17 @@ public class FpgaSocket implements IWebSocket {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void getConfigData(String appId, String userId) {
|
|
|
|
|
CupidLogUtils.e("FpgaSocket--->getConfigData appId: " + appId + ", userId:" + userId);
|
|
|
|
|
CupidLogUtils.i(TAG, "getConfigData appId: " + appId + ", userId:" + userId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void doConfigChanged(int type, String ip, List<FaceLoginResponse.DataBean.ConfigInfoHistoryBean> configInfos) {
|
|
|
|
|
CupidLogUtils.e("FpgaSocket--->doConfigChanged, type: " + type + " ip: " + ip + " configInfos:" + configInfos);
|
|
|
|
|
CupidLogUtils.i(TAG, "doConfigChanged, type: " + type + " ip: " + ip + " configInfos:" + configInfos);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void doConfigChanged(List<FaceLoginResponse.DataBean.ConfigInfoHistoryBean> configInfos) {
|
|
|
|
|
CupidLogUtils.e("FpgaSocket--->doConfigChanged, configInfos:" + configInfos);
|
|
|
|
|
CupidLogUtils.i(TAG, "doConfigChanged, configInfos:" + configInfos);
|
|
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
|
|
//上传配置信息
|
|
|
|
|
//位置信息 action是3
|
|
|
|
|
@@ -170,77 +171,77 @@ public class FpgaSocket implements IWebSocket {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void saveShotPic(Bitmap bitmap) {
|
|
|
|
|
CupidLogUtils.e("FpgaSocket--->saveShotPic");
|
|
|
|
|
CupidLogUtils.i(TAG, "saveShotPic");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void getTouchImage(String url, double x, double y) {
|
|
|
|
|
CupidLogUtils.e("FpgaSocket--->getTouchImage, url: " + url + " ,x: " + x + " ,y: " + y);
|
|
|
|
|
CupidLogUtils.i(TAG, "getTouchImage, url: " + url + " ,x: " + x + " ,y: " + y);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void doRecognizeImage(File file, String deviceId, String tag) {
|
|
|
|
|
CupidLogUtils.e("FpgaSocket--->doRecognizeImage");
|
|
|
|
|
CupidLogUtils.i(TAG, "doRecognizeImage");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void getUserAchieveInfo(String userId) {
|
|
|
|
|
CupidLogUtils.e("FpgaSocket--->getUserAchieveInfo, userId:" + userId);
|
|
|
|
|
CupidLogUtils.i(TAG, "getUserAchieveInfo, userId:" + userId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void getNaviInfo(int type) {
|
|
|
|
|
CupidLogUtils.e("FpgaSocket--->getNaviInfo, type:" + type);
|
|
|
|
|
CupidLogUtils.i(TAG, "getNaviInfo, type:" + type);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void syncMedalDetailInfo(String userId, int action, String medalType) {
|
|
|
|
|
CupidLogUtils.e("FpgaSocket--->syncMedalDetailInfo");
|
|
|
|
|
CupidLogUtils.i(TAG, "syncMedalDetailInfo");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void getCarModelInfo(String s, int id) {
|
|
|
|
|
CupidLogUtils.e("FpgaSocket--->getCarModelInfo");
|
|
|
|
|
CupidLogUtils.i(TAG, "getCarModelInfo");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void doUpdateCarInfo(String userId, String brandId, String brandName, String modelId, String modelName, String styleId, String styleName) {
|
|
|
|
|
CupidLogUtils.e("FpgaSocket--->doUpdateCarInfo");
|
|
|
|
|
CupidLogUtils.i(TAG, "doUpdateCarInfo");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void getApkAndFireWareInfo(String deviceId, String userId, int apkVersionCode, int xvideoCppVersionCode, int appId) {
|
|
|
|
|
CupidLogUtils.e("FpgaSocket--->getApkAndFireWareInfo");
|
|
|
|
|
CupidLogUtils.i(TAG, "getApkAndFireWareInfo");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void getFireWareBaseInfo(String baseUrl) {
|
|
|
|
|
CupidLogUtils.e("FpgaSocket--->getFireWareBaseInfo");
|
|
|
|
|
CupidLogUtils.i(TAG, "getFireWareBaseInfo");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void sendFirmWareUpdateInfo(String baseUrl, String json) {
|
|
|
|
|
CupidLogUtils.e("FpgaSocket--->sendFirmWareUpdateInfo");
|
|
|
|
|
CupidLogUtils.i(TAG, "sendFirmWareUpdateInfo");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void startNavigate(String userId, String naviStartName, String naviEndName) {
|
|
|
|
|
CupidLogUtils.e("FpgaSocket--->startNavigate");
|
|
|
|
|
CupidLogUtils.i(TAG, "startNavigate");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void syncUserNavigateInfo(String navigateId, String longtitude, String latitude, String poId, String currentSpeed) {
|
|
|
|
|
CupidLogUtils.e("FpgaSocket--->syncUserNavigateInfo");
|
|
|
|
|
CupidLogUtils.i(TAG, "syncUserNavigateInfo");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void doVerticalLineConfigCompleted() {
|
|
|
|
|
CupidLogUtils.e("FpgaSocket--->doVerticalLineConfigCompleted");
|
|
|
|
|
CupidLogUtils.i(TAG, "doVerticalLineConfigCompleted");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void doSyncCarSpaceInfo(String carLength, String carWidth, String carHeight) {
|
|
|
|
|
CupidLogUtils.e("FpgaSocket--->doSyncCarSpaceInfo");
|
|
|
|
|
CupidLogUtils.i(TAG, "doSyncCarSpaceInfo");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private IWebSocketConnectListener mWebSocketConnectListener;
|
|
|
|
|
@@ -270,7 +271,7 @@ public class FpgaSocket implements IWebSocket {
|
|
|
|
|
public void onOpen(WebSocket webSocket, Response response) {
|
|
|
|
|
super.onOpen(webSocket, response);
|
|
|
|
|
mWebSocket = webSocket;
|
|
|
|
|
CupidLogUtils.e("--->websocket response connect success");
|
|
|
|
|
CupidLogUtils.i(TAG, "websocket response connect success");
|
|
|
|
|
mWebSocketConnectListener.onWebSocketConnectSuccess(webSocket);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -282,7 +283,7 @@ public class FpgaSocket implements IWebSocket {
|
|
|
|
|
@Override
|
|
|
|
|
public void onMessage(WebSocket webSocket, String text) {
|
|
|
|
|
super.onMessage(webSocket, text);
|
|
|
|
|
CupidLogUtils.e("--->websocket response connect text" + text);
|
|
|
|
|
CupidLogUtils.i(TAG, "websocket response connect text" + text);
|
|
|
|
|
if (TextUtils.isEmpty(text)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
@@ -301,7 +302,7 @@ public class FpgaSocket implements IWebSocket {
|
|
|
|
|
@Override
|
|
|
|
|
public void onMessage(WebSocket webSocket, ByteString bytes) {
|
|
|
|
|
super.onMessage(webSocket, bytes);
|
|
|
|
|
CupidLogUtils.e("--->websocket response connect byte" + bytes.hex());
|
|
|
|
|
CupidLogUtils.i(TAG, "websocket response connect byte" + bytes.hex());
|
|
|
|
|
if (bytes == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
@@ -321,14 +322,14 @@ public class FpgaSocket implements IWebSocket {
|
|
|
|
|
public void onClosing(WebSocket webSocket, int code, String reason) {
|
|
|
|
|
super.onClosing(webSocket, code, reason);
|
|
|
|
|
mWebSocket = null;
|
|
|
|
|
CupidLogUtils.e("--->websocket onClosing==> onClosing" + reason);
|
|
|
|
|
CupidLogUtils.i(TAG, "websocket onClosing==> onClosing" + reason);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onClosed(WebSocket webSocket, int code, String reason) {
|
|
|
|
|
super.onClosed(webSocket, code, reason);
|
|
|
|
|
mWebSocket = null;
|
|
|
|
|
CupidLogUtils.e("--->websocket onClosed ==> " + reason);
|
|
|
|
|
CupidLogUtils.i(TAG, "websocket onClosed ==> " + reason);
|
|
|
|
|
mWebSocketConnectListener.onWebSocketConnectFailed(webSocket, reason);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -336,7 +337,7 @@ public class FpgaSocket implements IWebSocket {
|
|
|
|
|
public void onFailure(WebSocket webSocket, Throwable t, Response response) {
|
|
|
|
|
super.onFailure(webSocket, t, response);
|
|
|
|
|
mWebSocket = null;
|
|
|
|
|
CupidLogUtils.e("--->websocket onFailure ===>" + t.getMessage());
|
|
|
|
|
CupidLogUtils.i(TAG, "websocket onFailure ===>" + t.getMessage());
|
|
|
|
|
mWebSocketConnectListener.onWebSocketConnectFailed(webSocket, t.toString());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|