From 16c27b0ce03d44ec4672245961d23c6c860d4486 Mon Sep 17 00:00:00 2001 From: genxium Date: Sun, 19 Feb 2023 21:26:49 +0800 Subject: [PATCH] Minor fix. --- frontend/assets/scripts/WsSessionMgr.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/frontend/assets/scripts/WsSessionMgr.js b/frontend/assets/scripts/WsSessionMgr.js index f371df3..1f33261 100644 --- a/frontend/assets/scripts/WsSessionMgr.js +++ b/frontend/assets/scripts/WsSessionMgr.js @@ -271,13 +271,6 @@ window.initPersistentSessionClient = function(onopenCb, expectedRoomId) { clientSession.onclose = function(evt) { // [WARNING] The callback "onclose" might be called AFTER the webpage is refreshed with "1001 == evt.code". console.warn(`The WS clientSession is closed: evt=${JSON.stringify(evt)}, evt.code=${evt.code}`); - if (cc.sys.isNative) { - if (mapIns.frameDataLoggingEnabled) { - console.warn(`${mapIns._stringifyRdfIdToActuallyUsedInput()} -`); - } - DelayNoMore.UdpSession.closeUdpSession(); - } switch (evt.code) { case constants.RET_CODE.CLIENT_MISMATCHED_RENDER_FRAME: break; @@ -316,8 +309,18 @@ window.initPersistentSessionClient = function(onopenCb, expectedRoomId) { mapIns.popupSimplePressToGo("Disconnected unexpectedly, please retry", false, () => { window.clearLocalStorageAndBackToLoginScene(true); }); - break; default: + if (cc.sys.isNative) { + // [WARNING] This could be a BUG in CocosCreator JSB implementation of WebSocket client, the "evt.code" is always "undefined" in the "onclose" callback! + if (mapIns.frameDataLoggingEnabled) { + console.warn(`${mapIns._stringifyRdfIdToActuallyUsedInput()} +`); + } + DelayNoMore.UdpSession.closeUdpSession(); + mapIns.popupSimplePressToGo("Disconnected unexpectedly, please retry", false, () => { + window.clearLocalStorageAndBackToLoginScene(true); + }); + } break; } };