Commit 26d2fc6e by 钱炳权

修复websocket刷新数据丢失问题

parent b7729b83
...@@ -230,7 +230,8 @@ public class TestCmdTools { ...@@ -230,7 +230,8 @@ public class TestCmdTools {
} }
}).start(); }).start();
websocketClientServiceImpl.webSocketClient.send(data); websocketClientServiceImpl.webSocketClient.send(data);
} catch (Exception ignored) { } catch (Exception e) {
log.error("Web is disconnected:[{}]", e.getMessage());
} }
} }
} }
......
...@@ -54,8 +54,8 @@ public class WebSocket { ...@@ -54,8 +54,8 @@ public class WebSocket {
for (String name : WEBSOCKET_CONCURRENTHASHMAP.keySet()) { for (String name : WEBSOCKET_CONCURRENTHASHMAP.keySet()) {
if (this == WEBSOCKET_CONCURRENTHASHMAP.get(name)) { if (this == WEBSOCKET_CONCURRENTHASHMAP.get(name)) {
WEBSOCKET_CONCURRENTHASHMAP.remove(name); WEBSOCKET_CONCURRENTHASHMAP.remove(name);
log.info("The man {} disconnected! ", name);
break; break;
} }
} }
...@@ -103,8 +103,8 @@ public class WebSocket { ...@@ -103,8 +103,8 @@ public class WebSocket {
// WEBSOCKET_CONCURRENTHASHMAP.get(name).session.getBasicRemote().sendText(sender + ":" + message); // WEBSOCKET_CONCURRENTHASHMAP.get(name).session.getBasicRemote().sendText(sender + ":" + message);
WEBSOCKET_CONCURRENTHASHMAP.get(name).session.getBasicRemote().sendText(message); WEBSOCKET_CONCURRENTHASHMAP.get(name).session.getBasicRemote().sendText(message);
} catch (IOException e) { } catch (Exception e) {
e.printStackTrace(); log.error("Web is closed!");
} }
} }
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
} }
</script> </script>
<body onload="javascript:myFunction()"> <body onload="javascript:myFunction()">
<div id="sendDiv"> <div id="sendDiv"> ,
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment