Enhanced exception handling on frontend.

This commit is contained in:
genxium
2023-02-19 13:42:25 +08:00
parent 618531f5c6
commit 8b5a96e825
15 changed files with 172 additions and 139 deletions

View File

@@ -109,6 +109,7 @@ var constants = {
"GET_SMS_CAPTCHA_RESP_ERROR_CODE": 2023,
"SMS_CAPTCHA_REQUESTED_TOO_FREQUENTLY": 2024,
"SMS_CAPTCHA_NOT_MATCH": 2025,
"SAME_PLAYER_ALREADY_IN_SAME_ROOM": 2026,
"NOT_IMPLEMENTED_YET": 65535
},

View File

@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.2" tiledversion="1.2.3" orientation="orthogonal" renderorder="right-down" width="128" height="40" tilewidth="16" tileheight="16" infinite="0" nextlayerid="8" nextobjectid="138">
<map version="1.2" tiledversion="1.2.3" orientation="orthogonal" renderorder="right-down" width="128" height="64" tilewidth="16" tileheight="16" infinite="0" nextlayerid="9" nextobjectid="138">
<tileset firstgid="1" source="tiles0.tsx"/>
<tileset firstgid="65" source="tiles1.tsx"/>
<tileset firstgid="129" source="tiles2.tsx"/>
<layer id="7" name="Ground" width="128" height="40">
<layer id="8" name="Ground" width="128" height="64">
<data encoding="base64" compression="zlib">
eJzt2k0OgjAQQGECccMOo+5JvIlx484LeP9jaAxNSEOhlMGZOG/xbfyl81rc2FRV1QAAAAAAAAAAAADAD9zxpd1Bs7/2NWjzPAPPa2cGvtfODHyvnRn4XjszKFv7KdOW6zoKvYb+9vpf6W+G5f5zfZeep7/82kM3qf6Hj25C3DhFYwb/pqT/VlKfQ///7z91f+g2fj/9y/tLWbqfp7rvsQ/ob0tue6l9YHEGlvv3Qq+hv77x2tuBdv/SPVC6P7z3v0XCc/HjQZ8p9X5rwgy0W2j1rwfh/L8+Hgm1gNQZlfjsku/2fv7j/uPfgPFjUv010T/d/xH1niLd47KDNfcc+s/3aRdml2Opv/R+ov+6/ufB3Ny2nP+5PbD3+c/Zn/RP95f8zaW/Pdr/u7ZCu4Nm/6dz9Pdtz/5vZSq2hg==
eJzt2j1uwkAQgFEESkNHlKRHyk2iNHRcIPc/RlCEJWSxtrHHmRX7itfw651v1zTsNpvNDgAAAAAAAOAffPMnu0Nm/+xryNbyDFpeuxm0vXYzaHvtZtD22s1g3trfJlpyXa9Br9G/vv6f+lej5v5Dfcee1z9+7V23qP4vF4c7+o1LMmbwbOb0Xyrqc/R//v737g+Hhd+v//z+Ucbu56Xua+wD/esytX3UPqhxBjX3Pwa9Rv98t2vfX2X3n7sH5u6P1vt/9XTP9R/vHCcqvb823QyyW2T131515//n4lSwDVA6oxGfPee7Wz///f63vwG3j0X1z6R/uf+p1/ue6B4fK3jknqP/cJ/9yOymGOsfvZ/0f6z/+9XQ3Jac/6E9sPb5n7I/9S/3j/zN1b8+2f+7rkV2h8z+58bp37Y1+x8qlz37WmR30F9//fXXX38AAAAAAAAAAAAg1y8jXMSV
</data>
</layer>
<objectgroup id="1" name="PlayerStartingPos">

View File

@@ -22,6 +22,9 @@
},
{
"__id__": 5
},
{
"__id__": 11
}
],
"_active": true,
@@ -192,102 +195,28 @@
"fileId": "ab6G+s0otA4rXhUsO3czRN",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "VerticalLayout",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [
{
"__id__": 6
},
{
"__id__": 12
}
],
"_active": true,
"_components": [
{
"__id__": 53
},
{
"__id__": 54
}
],
"_prefab": {
"__id__": 55
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 960,
"height": 265
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
-9.924,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Node",
"_name": "exitButton",
"_objFlags": 0,
"_parent": {
"__id__": 5
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 6
},
{
"__id__": 7
},
{
"__id__": 8
},
{
"__id__": 10
"__id__": 9
}
],
"_prefab": {
"__id__": 11
"__id__": 10
},
"_opacity": 255,
"_color": {
@@ -312,7 +241,7 @@
"ctor": "Float64Array",
"array": [
-379.577,
100.5,
90.576,
0,
0,
0,
@@ -341,7 +270,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 6
"__id__": 5
},
"_enabled": true,
"_materials": [
@@ -375,7 +304,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 6
"__id__": 5
},
"_enabled": true,
"_normalMaterial": null,
@@ -384,7 +313,7 @@
"zoomScale": 1.2,
"clickEvents": [
{
"__id__": 9
"__id__": 8
}
],
"_N$interactable": true,
@@ -440,7 +369,7 @@
"hoverSprite": null,
"_N$disabledSprite": null,
"_N$target": {
"__id__": 6
"__id__": 5
},
"_id": ""
},
@@ -459,7 +388,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 6
"__id__": 5
},
"_enabled": true,
"alignMode": 1,
@@ -489,15 +418,86 @@
"asset": {
"__uuid__": "dc804c5c-ff76-445e-ac69-52269055c3c5"
},
"fileId": "1cUg34ZtdK9JfdGIG+lpdF",
"fileId": "3cdlb7LxhMzLDzxdQv8Z/x",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "VerticalLayout",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [
{
"__id__": 12
}
],
"_active": true,
"_components": [
{
"__id__": 53
},
{
"__id__": 54
}
],
"_prefab": {
"__id__": 55
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 960,
"height": 137
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
-68.939,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Node",
"_name": "HorizontalLayout",
"_objFlags": 0,
"_parent": {
"__id__": 5
"__id__": 11
},
"_children": [
{
@@ -545,7 +545,7 @@
"ctor": "Float64Array",
"array": [
0,
-64,
0,
0,
0,
0,
@@ -1953,7 +1953,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 5
"__id__": 11
},
"_enabled": true,
"_materials": [
@@ -1983,13 +1983,13 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 5
"__id__": 11
},
"_enabled": true,
"_layoutSize": {
"__type__": "cc.Size",
"width": 960,
"height": 265
"height": 137
},
"_resize": 1,
"_N$layoutType": 2,
@@ -2040,7 +2040,7 @@
"__id__": 43
},
"exitBtnNode": {
"__id__": 6
"__id__": 5
},
"_id": ""
},

View File

@@ -536,7 +536,7 @@
"array": [
0,
0,
216.65450766436658,
216.05530045313827,
0,
0,
0,

View File

@@ -461,7 +461,7 @@
"array": [
0,
0,
209.66956379694378,
209.7452601621179,
0,
0,
0,

View File

@@ -518,7 +518,7 @@
"array": [
0,
0,
216.50635094610968,
216.05530045313827,
0,
0,
0,

View File

@@ -293,7 +293,7 @@ cc.Class({
}
},
popupSimplePressToGo(labelString, hideYesButton) {
popupSimplePressToGo(labelString, hideYesButton, additionalOnDismissalCb) {
const self = this;
self.state = ALL_MAP_STATES.SHOWING_MODAL_POPUP;
@@ -306,6 +306,9 @@ cc.Class({
const postDismissalByYes = () => {
self.transitToState(ALL_MAP_STATES.VISUAL);
canvasNode.removeChild(simplePressToGoDialogNode);
if (additionalOnDismissalCb) {
additionalOnDismissalCb();
}
}
simplePressToGoDialogNode.getChildByName("Hint").getComponent(cc.Label).string = labelString;
yesButton.once("click", simplePressToGoDialogScriptIns.dismissDialog.bind(simplePressToGoDialogScriptIns, postDismissalByYes));

View File

@@ -288,13 +288,21 @@ window.initPersistentSessionClient = function(onopenCb, expectedRoomId) {
`);
}
break;
case constants.RET_CODE.SAME_PLAYER_ALREADY_IN_SAME_ROOM:
mapIns.popupSimplePressToGo("You just logged into a conflicting account, please use a different account to retry", false, () => {
window.clearLocalStorageAndBackToLoginScene(true);
});
break;
case constants.RET_CODE.PLAYER_NOT_ADDABLE_TO_ROOM:
case constants.RET_CODE.PLAYER_NOT_READDABLE_TO_ROOM:
window.clearBoundRoomIdInBothVolatileAndPersistentStorage(); // To favor the player to join other rooms
mapIns.onManualRejoinRequired("Couldn't join any room at the moment, please retry");
mapIns.popupSimplePressToGo("Couldn't join any room at the moment, please retry", false, () => {
window.clearLocalStorageAndBackToLoginScene(true);
});
break;
case constants.RET_CODE.ACTIVE_WATCHDOG:
mapIns.onManualRejoinRequired("Disconnected due to long-time inactivity, please rejoin");
mapIns.popupSimplePressToGo("Couldn't join any room at the moment, please retry", false, () => {
window.clearLocalStorageAndBackToLoginScene(true);
});
break;
case constants.RET_CODE.UNKNOWN_ERROR:
case constants.RET_CODE.MYSQL_ERROR:
@@ -305,7 +313,9 @@ window.initPersistentSessionClient = function(onopenCb, expectedRoomId) {
console.warn(`${mapIns._stringifyRdfIdToActuallyUsedInput()}
`);
}
window.clearLocalStorageAndBackToLoginScene(true);
mapIns.popupSimplePressToGo("Disconnected unexpectedly, please retry", false, () => {
window.clearLocalStorageAndBackToLoginScene(true);
});
break;
default:
break;