1、增加websocket保活
This commit is contained in:
parent
22894c69c8
commit
b99ac8e11b
@ -38,7 +38,7 @@ public class WebSocketServer {
|
|||||||
|
|
||||||
@OnMessage
|
@OnMessage
|
||||||
public void onMessage(String msg, Session session){
|
public void onMessage(String msg, Session session){
|
||||||
log.info("websocket: "+msg);
|
//log.info("websocket: "+msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnError
|
@OnError
|
||||||
|
|||||||
@ -157,13 +157,14 @@
|
|||||||
layui.layer.alert("Open web socket failed!");
|
layui.layer.alert("Open web socket failed!");
|
||||||
}
|
}
|
||||||
websocket.onclose = function (){
|
websocket.onclose = function (){
|
||||||
rxWin.append("websocket closed!\r\n");
|
rxWin.val("websocket closed!\r\n");
|
||||||
// 如果需要停止重复执行的定时任务
|
// 如果需要停止重复执行的定时任务
|
||||||
clearInterval(intervalId);
|
clearInterval(intervalId);
|
||||||
}
|
}
|
||||||
//接收信息
|
//接收信息
|
||||||
websocket.onmessage = function (event) {
|
websocket.onmessage = function (event) {
|
||||||
rxWin.append(event.data + "\r\n");
|
console.log("event.data");
|
||||||
|
rxWin.val(rxWin.val()+event.data + "\r\n");
|
||||||
rxWin.scrollTop = rxWin.scrollHeight;
|
rxWin.scrollTop = rxWin.scrollHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user