mirror of
https://github.com/hanzozt/zt.git
synced 2026-11-03 05:01:58 +00:00
- Repo names: ziti-* → zt-* - Go modules: github.com/hanzozt/ziti → github.com/hanzozt/zt - Docker images: hanzozt/ziti-* → hanzozt/zt-* - C/Java/JS symbols: ziti_* → zt_* - File and directory names updated
26 lines
575 B
JavaScript
26 lines
575 B
JavaScript
var webSocket;
|
|
|
|
function openWebSocket() {
|
|
if (webSocket !== undefined && webSocket.readyState !== WebSocket.CLOSED) {
|
|
return;
|
|
}
|
|
webSocket = new WebSocket("ws://localhost:8080/metrics");
|
|
|
|
webSocket.onmessage = function (event) {
|
|
let msg = $.parseJSON(event.data);
|
|
processMessage(msg);
|
|
};
|
|
|
|
webSocket.onclose = function (event) {
|
|
console.log("connection closed");
|
|
};
|
|
}
|
|
|
|
$(window).on('beforeunload', function(){
|
|
webSocket.close();
|
|
console.log("closed websocket");
|
|
});
|
|
|
|
(function () {
|
|
openWebSocket();
|
|
})(); |