Better close of websocket handling

merge-requests/237/merge
Tag 2023-02-22 16:51:31 -08:00
rodzic c9f2e60163
commit 26af8c66ac
2 zmienionych plików z 16 dodań i 20 usunięć

Wyświetl plik

@ -2719,6 +2719,7 @@ function onRightClickGridSquare(feature)
new_win.on("loaded", function () new_win.on("loaded", function ()
{ {
GT.popupWindowHandle.show(); GT.popupWindowHandle.show();
GT.popupWindowHandle.focus();
renderTooltipWindow(feature); renderTooltipWindow(feature);
}); });
new_win.on("close", function () new_win.on("close", function ()
@ -7727,9 +7728,9 @@ function resetSearch()
GT.lastSearchSelection = null; GT.lastSearchSelection = null;
} }
function showWorkedByCall(callsign, evt) function showWorkedByCall(callsign, event)
{ {
evt.preventDefault(); event.preventDefault();
resetSearch(); resetSearch();
GT.searchWB = callsign; GT.searchWB = callsign;
@ -7830,10 +7831,7 @@ function showWorkedBox(sortIndex, nextPage, redraw)
bands[list[key].band] = list[key].band; bands[list[key].band] = list[key].band;
modes[list[key].mode] = list[key].mode; modes[list[key].mode] = list[key].mode;
var unconfirmedCallsKey = new UnconfirmedCallsKey(list[key].dxcc, list[key].band); var unconfirmedCallsKey = new UnconfirmedCallsKey(list[key].dxcc, list[key].band);
if ( if (GT.unconfirmedCalls.has(unconfirmedCallsKey.key) && list[key].confirmed)
GT.unconfirmedCalls.has(unconfirmedCallsKey.key) &&
list[key].confirmed
)
{ {
GT.unconfirmedCalls.set(unconfirmedCallsKey.key, GT.unconfirmedCallsSentinel); GT.unconfirmedCalls.set(unconfirmedCallsKey.key, GT.unconfirmedCallsSentinel);
} }
@ -8447,6 +8445,7 @@ function showDXCCsBox()
new_win.on("loaded", function () new_win.on("loaded", function ()
{ {
GT.popupWindowHandle.show(); GT.popupWindowHandle.show();
GT.popupWindowHandle.focus();
renderTooltipWindowLogbook(GT.unconfirmedCalls.get(unconfirmedCallsKey.key)); renderTooltipWindowLogbook(GT.unconfirmedCalls.get(unconfirmedCallsKey.key));
}); });
new_win.on("close", function () new_win.on("close", function ()

Wyświetl plik

@ -120,11 +120,14 @@ function gtConnectChat()
GT.gtChatSocket.onerror = function () GT.gtChatSocket.onerror = function ()
{ {
this.close();
GT.gtChatSocket = null;
GT.gtState = ChatState.error; GT.gtState = ChatState.error;
}; };
GT.gtChatSocket.onclose = function () GT.gtChatSocket.onclose = function ()
{ {
GT.gtChatSocket = null;
GT.gtState = ChatState.closed; GT.gtState = ChatState.closed;
}; };
} }
@ -151,20 +154,20 @@ function closeGtSocket()
{ {
gtChatSendClose(); gtChatSendClose();
if (GT.gtChatSocket.readyState != WebSocket.CLOSED) GT.gtChatSocket.close(); GT.gtChatSocket.close();
GT.gtChatSocket = null;
if (GT.gtChatSocket.readyState === WebSocket.CLOSED) GT.gtState = ChatState.none;
{
GT.gtChatSocket = null;
GT.gtState = ChatState.none;
}
} }
else GT.gtState = ChatState.none; else GT.gtState = ChatState.none;
} }
function gtClosedSocket() function gtClosedSocket()
{ {
GT.gtChatSocket = null; if (GT.gtChatSocket != null)
{
GT.gtChatSocket.close();
GT.gtChatSocket = null;
}
GT.gtState = ChatState.none; GT.gtState = ChatState.none;
} }
@ -320,12 +323,6 @@ function gtChatRemoveCall(jsmesg)
{ {
delete GT.gtFlagPins[cid].ids[id]; delete GT.gtFlagPins[cid].ids[id];
} }
else
{
console.log("drop: No such id in GT.gtFlagPins.ids:");
console.log(jsmesg);
console.log(GT.gtFlagPins[cid].ids);
}
if (Object.keys(GT.gtFlagPins[cid].ids).length == 0) if (Object.keys(GT.gtFlagPins[cid].ids).length == 0)
{ {