jinpengyong
2020-09-21 c06d969f9486912606064092d7f4946c4abc2395
webscoket关闭
1 files modified
19 ■■■■■ changed files
src/main/webapp/view/newmap.jsp 19 ●●●●● patch | view | raw | blame | history
src/main/webapp/view/newmap.jsp
@@ -365,7 +365,12 @@
    }
</style>
<body>
<div>
</div>
<textarea id="close" hidden></textarea>
<div class="main_body">
    <%--<input  id="button" type="button" value="点击" onclick="getJs();">--%>
    <div class="tools_box">
        <div class="charts_btn">
        </div>
@@ -697,7 +702,6 @@
            ws = new WebSocket('ws://' + hostAndPort + '/screen/webSocket/' + orgId + '&' + accountId + '_' + regionCode);
            ws.onopen = function () {
            };
            //获得消息事件
            ws.onmessage = function (msg) {
                // $("#searchParam").val(JSON.parse(msg.data));
@@ -707,12 +711,18 @@
                  }*/
            };
            if ($("#close").html()=="CloseMq") {
                ws.close();
            }
            //关闭事件
            ws.onclose = function () {
                $("#close").html("websocket已经关闭");
            };
            //发生了错误事件
            ws.onerror = function () {
                $("#close").html("websocket关闭错误");
            };
        }
    })(jQuery);
@@ -820,6 +830,7 @@
    }
    function callJS(jsonData) {
        $("#close").html(jsonData);
        var jsonData = JSON.parse(jsonData);
        var methodName = jsonData.methodName;
        // $("#searchParam").val(JSON.stringify(jsonData));
@@ -829,7 +840,13 @@
            var states = jsonData.states;
            moralMap.refreshState(states);
        } else if ("DeliverSensors" == methodName) {
            $("#close").html(methodName);
            moralMap.showSensors(jsonData);
        } else if ("CloseMq" == methodName) {
            //window.location = "http://www.baidu.com"
            $("#close").html(methodName);
        }
    }
</script>