📅  最后修改于: 2022-03-11 14:59:19.145000             🧑  作者: Mango
let timerID = 0;
function keepAlive() {
let timeout = 15000;
if (webSocket.readyState == webSocket.OPEN) {
webSocket.send('');
}
timerId = setTimeout(keepAlive, timeout);
}
function cancelKeepAlive() {
if (timerId) {
cancelTimeout(timerId);
}
}