|
@@ -3,6 +3,7 @@ package com.huimv.wine.ws;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.huimv.wine.common.EventWsErrUtil;
|
|
|
import com.huimv.wine.entity.Device;
|
|
|
import com.huimv.wine.entity.vo.WsEvent;
|
|
|
import com.huimv.wine.mapper.DeviceMapper;
|
|
@@ -41,7 +42,9 @@ public class DebuggerController extends TextWebSocketHandler {
|
|
|
@OnOpen
|
|
|
public void onOpen(@PathParam(value = "id") String id, Session session) {
|
|
|
//需要判断id是否为空
|
|
|
-
|
|
|
+ if ("".equals(id) || null == id) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
// 添加到session的映射关系中
|
|
|
WebsocketDebuggerUtil.addSession(id, session);
|
|
|
}
|
|
@@ -133,7 +136,7 @@ public class DebuggerController extends TextWebSocketHandler {
|
|
|
WsEvent wsEvent = new WsEvent("setDebug", debug);
|
|
|
WebsocketDebuggerUtil.sendMessage(sessions.get("seq"), wsEvent);
|
|
|
} else {
|
|
|
- WsEvent wsEvent = new WsEvent("__Error_Event__", "device offline/no such device");
|
|
|
+ WsEvent wsEvent =EventWsErrUtil.getWsErr("device offline/no such device");
|
|
|
WebsocketDebuggerUtil.sendMessage(session, wsEvent);
|
|
|
}
|
|
|
}
|
|
@@ -174,7 +177,7 @@ public class DebuggerController extends TextWebSocketHandler {
|
|
|
WsEvent wsEvent1 = new WsEvent("authCode", new Result(10000, formattedNumber, true));
|
|
|
WebsocketDebuggerUtil.sendMessage(session, wsEvent1);
|
|
|
} else {
|
|
|
- WsEvent wsEvent = new WsEvent("authCode", "device offline");
|
|
|
+ WsEvent wsEvent =EventWsErrUtil.getWsErr("device offline");
|
|
|
WebsocketDebuggerUtil.sendMessage(session, wsEvent);
|
|
|
}
|
|
|
|
|
@@ -189,7 +192,7 @@ public class DebuggerController extends TextWebSocketHandler {
|
|
|
device.setAddr(loc);
|
|
|
int i = deviceMapper.updateById(device);
|
|
|
if (i == 0) {
|
|
|
- WsEvent wsEvent = new WsEvent("__Error_Event__", "update location failed");
|
|
|
+ WsEvent wsEvent =EventWsErrUtil.getWsErr("update location failed");
|
|
|
WebsocketDebuggerUtil.sendMessage(session, wsEvent);
|
|
|
} else {
|
|
|
WsEvent wsEvent = new WsEvent("locationUpdated", null);
|
|
@@ -216,7 +219,7 @@ public class DebuggerController extends TextWebSocketHandler {
|
|
|
}
|
|
|
int update = deviceMapper.updateById(device);
|
|
|
if (update == 0) {
|
|
|
- WsEvent wsEvent = new WsEvent("__Error_Event__", "update vpp failed");
|
|
|
+ WsEvent wsEvent =EventWsErrUtil.getWsErr("update vpp failed");
|
|
|
WebsocketDebuggerUtil.sendMessage(session, wsEvent);
|
|
|
}
|
|
|
|
|
@@ -229,7 +232,7 @@ public class DebuggerController extends TextWebSocketHandler {
|
|
|
WsEvent wsEvent = new WsEvent("vppUpdate", jsonObject1);
|
|
|
WebsocketDebuggerUtil.sendMessage(sessions.get("seq"), wsEvent);
|
|
|
} else {
|
|
|
- WsEvent wsEvent = new WsEvent("__Error_Event__", "device offline/no such device");
|
|
|
+ WsEvent wsEvent =EventWsErrUtil.getWsErr("device offline/no such device");
|
|
|
WebsocketDebuggerUtil.sendMessage(session, wsEvent);
|
|
|
}
|
|
|
}
|