|
|
|
@ -34,7 +34,6 @@ public class WebSocketComponent implements CommandLineRunner {
|
|
|
|
|
SocketMsgService socketMsgService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
IoStatOrderService statOrderService;
|
|
|
|
|
|
|
|
|
@ -49,21 +48,20 @@ public class WebSocketComponent implements CommandLineRunner {
|
|
|
|
|
SpsWebSocketClient client = new SpsWebSocketClient("ws://" + ip + "/sps/web/sync/2/" + socketToken);
|
|
|
|
|
client.setSocketMsgService(socketMsgService);
|
|
|
|
|
initConnect(client);
|
|
|
|
|
//等待服务端响应
|
|
|
|
|
while (!client.getReadyState().equals(ReadyState.OPEN)) {
|
|
|
|
|
// log.info("连接中···请稍后");
|
|
|
|
|
Thread.sleep(1000);
|
|
|
|
|
}
|
|
|
|
|
//等待WebSocket服务端响应
|
|
|
|
|
String message = null;
|
|
|
|
|
while (true) {
|
|
|
|
|
while ((message = client.getExcptMessage()) == null) {
|
|
|
|
|
log.info("已连接,等待接收数据--------");
|
|
|
|
|
Thread.sleep(1000);
|
|
|
|
|
if (client.isClosed()) {
|
|
|
|
|
initConnect(client);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
log.info("接收到服务端消息:" + message);
|
|
|
|
|
if (message.equals(SocketMsgType.DL_ALL_DATA)) {
|
|
|
|
|
heartTaskService.pullData(null);
|
|
|
|
|
}
|
|
|
|
|