mirror of
https://github.com/genxium/DelayNoMore
synced 2025-10-09 16:46:38 +00:00
Fixed recovery upon reconnection.
This commit is contained in:
@@ -86,8 +86,8 @@ cc.Class({
|
||||
self.smsLoginCaptchaLabel.active = true;
|
||||
|
||||
self.loginButton.active = true;
|
||||
self.onLoginButtonClicked = self.onLoginButtonClicked.bind(self);
|
||||
self.onSMSCaptchaGetButtonClicked = self.onSMSCaptchaGetButtonClicked.bind(self);
|
||||
self.onLoginButtonClicked = self.onLoginButtonClicked.bind(self);
|
||||
self.onSMSCaptchaGetButtonClicked = self.onSMSCaptchaGetButtonClicked.bind(self);
|
||||
self.smsLoginCaptchaButton.on('click', self.onSMSCaptchaGetButtonClicked);
|
||||
|
||||
self.loadingNode = cc.instantiate(this.loadingPrefab);
|
||||
@@ -98,6 +98,17 @@ cc.Class({
|
||||
if (null != qDict && qDict["expectedRoomId"]) {
|
||||
window.clearBoundRoomIdInBothVolatileAndPersistentStorage();
|
||||
}
|
||||
|
||||
self.checkIntAuthTokenExpire().then(
|
||||
(intAuthToken) => {
|
||||
console.log("Successfully found `intAuthToken` in local cache");
|
||||
self.useTokenLogin(intAuthToken);
|
||||
},
|
||||
() => {
|
||||
console.warn("Failed to find `intAuthToken` in local cache");
|
||||
window.clearBoundRoomIdInBothVolatileAndPersistentStorage();
|
||||
}
|
||||
);
|
||||
},
|
||||
|
||||
getRetCodeList() {
|
||||
@@ -185,28 +196,28 @@ cc.Class({
|
||||
checkIntAuthTokenExpire() {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!cc.sys.localStorage.getItem('selfPlayer')) {
|
||||
console.warn("Couldn't find selfPlayer key in local cache");
|
||||
console.warn("Couldn't find selfPlayer key in local cache");
|
||||
reject();
|
||||
return;
|
||||
}
|
||||
const selfPlayer = JSON.parse(cc.sys.localStorage.getItem('selfPlayer'));
|
||||
if (null == selfPlayer) {
|
||||
console.warn("Couldn't find selfPlayer object in local cache");
|
||||
reject();
|
||||
return;
|
||||
}
|
||||
|
||||
if (null == selfPlayer.intAuthToken) {
|
||||
console.warn("Couldn't find selfPlayer object with key `intAuthToken` in local cache");
|
||||
reject();
|
||||
return;
|
||||
}
|
||||
if (new Date().getTime() > selfPlayer.expiresAt) {
|
||||
console.warn("Couldn't find unexpired selfPlayer `intAuthToken` in local cache");
|
||||
reject();
|
||||
return;
|
||||
if (null == selfPlayer) {
|
||||
console.warn("Couldn't find selfPlayer object in local cache");
|
||||
reject();
|
||||
return;
|
||||
}
|
||||
resolve(selfPlayer.intAuthToken);
|
||||
|
||||
if (null == selfPlayer.intAuthToken) {
|
||||
console.warn("Couldn't find selfPlayer object with key `intAuthToken` in local cache");
|
||||
reject();
|
||||
return;
|
||||
}
|
||||
if (new Date().getTime() > selfPlayer.expiresAt) {
|
||||
console.warn("Couldn't find unexpired selfPlayer `intAuthToken` in local cache");
|
||||
reject();
|
||||
return;
|
||||
}
|
||||
resolve(selfPlayer.intAuthToken);
|
||||
})
|
||||
},
|
||||
|
||||
@@ -343,7 +354,7 @@ cc.Class({
|
||||
);
|
||||
cc.director.loadScene('default_map');
|
||||
} else {
|
||||
console.log("OnLoggedIn failed, about to remove `selfPlayer` in local cache.")
|
||||
console.log("OnLoggedIn failed, about to remove `selfPlayer` in local cache.")
|
||||
cc.sys.localStorage.removeItem("selfPlayer");
|
||||
window.clearBoundRoomIdInBothVolatileAndPersistentStorage();
|
||||
self.enableInteractiveControls(true);
|
||||
|
@@ -479,32 +479,34 @@ cc.Class({
|
||||
const dx = boundaryObj[i].x - x0;
|
||||
const dy = boundaryObj[i].y - y0;
|
||||
pts.push([dx, dy]);
|
||||
if (self.showCriticalCoordinateLabels) {
|
||||
const barrierVertLabelNode = new cc.Node();
|
||||
switch (i % 4) {
|
||||
case 0:
|
||||
barrierVertLabelNode.color = cc.Color.RED;
|
||||
break;
|
||||
case 1:
|
||||
barrierVertLabelNode.color = cc.Color.GRAY;
|
||||
break;
|
||||
case 2:
|
||||
barrierVertLabelNode.color = cc.Color.BLACK;
|
||||
break;
|
||||
default:
|
||||
barrierVertLabelNode.color = cc.Color.MAGENTA;
|
||||
break;
|
||||
}
|
||||
barrierVertLabelNode.setPosition(cc.v2(x0+0.95*dx, y0+0.5*dy));
|
||||
const barrierVertLabel = barrierVertLabelNode.addComponent(cc.Label);
|
||||
barrierVertLabel.fontSize = 20;
|
||||
barrierVertLabel.lineHeight = 22;
|
||||
barrierVertLabel.string = `(${boundaryObj[i].x.toFixed(1)}, ${boundaryObj[i].y.toFixed(1)})`;
|
||||
safelyAddChild(self.node, barrierVertLabelNode);
|
||||
setLocalZOrder(barrierVertLabelNode, 5);
|
||||
|
||||
barrierVertLabelNode.active = true;
|
||||
/*
|
||||
if (self.showCriticalCoordinateLabels) {
|
||||
const barrierVertLabelNode = new cc.Node();
|
||||
switch (i % 4) {
|
||||
case 0:
|
||||
barrierVertLabelNode.color = cc.Color.RED;
|
||||
break;
|
||||
case 1:
|
||||
barrierVertLabelNode.color = cc.Color.GRAY;
|
||||
break;
|
||||
case 2:
|
||||
barrierVertLabelNode.color = cc.Color.BLACK;
|
||||
break;
|
||||
default:
|
||||
barrierVertLabelNode.color = cc.Color.MAGENTA;
|
||||
break;
|
||||
}
|
||||
barrierVertLabelNode.setPosition(cc.v2(x0+0.95*dx, y0+0.5*dy));
|
||||
const barrierVertLabel = barrierVertLabelNode.addComponent(cc.Label);
|
||||
barrierVertLabel.fontSize = 20;
|
||||
barrierVertLabel.lineHeight = 22;
|
||||
barrierVertLabel.string = `(${boundaryObj[i].x.toFixed(1)}, ${boundaryObj[i].y.toFixed(1)})`;
|
||||
safelyAddChild(self.node, barrierVertLabelNode);
|
||||
setLocalZOrder(barrierVertLabelNode, 5);
|
||||
|
||||
barrierVertLabelNode.active = true;
|
||||
}
|
||||
*/
|
||||
}
|
||||
const newBarrier = self.collisionSys.createPolygon(x0, y0, pts);
|
||||
// console.log("Created barrier: ", newBarrier);
|
||||
@@ -797,8 +799,8 @@ cc.Class({
|
||||
newPlayerNode.active = true;
|
||||
const playerScriptIns = newPlayerNode.getComponent("SelfPlayer");
|
||||
playerScriptIns.scheduleNewDirection({
|
||||
dx: 0,
|
||||
dy: 0
|
||||
dx: playerRichInfo.dir.dx,
|
||||
dy: playerRichInfo.dir.dy
|
||||
}, true);
|
||||
|
||||
return [newPlayerNode, playerScriptIns];
|
||||
@@ -943,10 +945,13 @@ cc.Class({
|
||||
setLocalZOrder(toShowNode, 10);
|
||||
},
|
||||
|
||||
hideFindingPlayersGUI() {
|
||||
hideFindingPlayersGUI(rdf) {
|
||||
const self = this;
|
||||
if (null == self.findingPlayerNode.parent) return;
|
||||
self.findingPlayerNode.parent.removeChild(self.findingPlayerNode);
|
||||
if (null != rdf) {
|
||||
self._initPlayerRichInfoDict(rdf.players, rdf.playerMetas);
|
||||
}
|
||||
},
|
||||
|
||||
onBattleReadyToStart(rdf) {
|
||||
|
@@ -156,7 +156,7 @@ window.initPersistentSessionClient = function(onopenCb, expectedRoomId) {
|
||||
break;
|
||||
case window.DOWNSYNC_MSG_ACT_PLAYER_READDED_AND_ACKED:
|
||||
// Deliberately left blank for now
|
||||
mapIns.hideFindingPlayersGUI();
|
||||
mapIns.hideFindingPlayersGUI(resp.rdf);
|
||||
break;
|
||||
case window.DOWNSYNC_MSG_ACT_BATTLE_READY_TO_START:
|
||||
mapIns.onBattleReadyToStart(resp.rdf);
|
||||
|
Reference in New Issue
Block a user