|
@@ -38,15 +38,20 @@ export default class HttpRequest {
|
|
let r = new XMLHttpRequest()
|
|
let r = new XMLHttpRequest()
|
|
r.open("GET", path + `?x=${isJiami ? 1 : 0}`, true)
|
|
r.open("GET", path + `?x=${isJiami ? 1 : 0}`, true)
|
|
r.timeout = this.timeoutMs
|
|
r.timeout = this.timeoutMs
|
|
|
|
+ let isTimeOut = false;
|
|
|
|
+ let isError = false;
|
|
r.onerror = () => {
|
|
r.onerror = () => {
|
|
|
|
+ isError = true;
|
|
console.log("发生错误,url=", path)
|
|
console.log("发生错误,url=", path)
|
|
callback({})
|
|
callback({})
|
|
}
|
|
}
|
|
r.ontimeout = () => {
|
|
r.ontimeout = () => {
|
|
|
|
+ isTimeOut = true;
|
|
console.log("超时了,url=", path)
|
|
console.log("超时了,url=", path)
|
|
callback({})
|
|
callback({})
|
|
}
|
|
}
|
|
r.onloadend = function () {
|
|
r.onloadend = function () {
|
|
|
|
+ if (isTimeOut || isError) return;
|
|
let temp = {}
|
|
let temp = {}
|
|
if (r.status >= 200 && r.status <= 400 && r.readyState == 4) {
|
|
if (r.status >= 200 && r.status <= 400 && r.readyState == 4) {
|
|
let txt = gameMethod.xorEncrypt(r.response, isJiami);
|
|
let txt = gameMethod.xorEncrypt(r.response, isJiami);
|
|
@@ -157,21 +162,21 @@ export default class HttpRequest {
|
|
}
|
|
}
|
|
|
|
|
|
// try {
|
|
// try {
|
|
- if (temp && Object.keys(temp).length > 0) {
|
|
|
|
- if (CC_JSB) {
|
|
|
|
- if (!gameMethod.isEmpty(GameDataCenter.sevBack) && !gameMethod.isEmpty(GameDataCenter.sevBack.switch) && !gameMethod.isEmpty(GameDataCenter.sevBack.switch.clientLog)) {
|
|
|
|
- console.warn("S->C:", JSON.stringify(temp))
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- if (!gameMethod.isEmpty(GameDataCenter.sevBack) && !gameMethod.isEmpty(GameDataCenter.sevBack.switch) && !gameMethod.isEmpty(GameDataCenter.sevBack.switch.clientLog)) {
|
|
|
|
- console.warn("S->C:", temp)
|
|
|
|
- }
|
|
|
|
|
|
+ if (temp && Object.keys(temp).length > 0) {
|
|
|
|
+ if (CC_JSB) {
|
|
|
|
+ if (!gameMethod.isEmpty(GameDataCenter.sevBack) && !gameMethod.isEmpty(GameDataCenter.sevBack.switch) && !gameMethod.isEmpty(GameDataCenter.sevBack.switch.clientLog)) {
|
|
|
|
+ console.warn("S->C:", JSON.stringify(temp))
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ if (!gameMethod.isEmpty(GameDataCenter.sevBack) && !gameMethod.isEmpty(GameDataCenter.sevBack.switch) && !gameMethod.isEmpty(GameDataCenter.sevBack.switch.clientLog)) {
|
|
|
|
+ console.warn("S->C:", temp)
|
|
}
|
|
}
|
|
- //请求成功移除缓存的消息请求
|
|
|
|
- this.errPostMap.Remove(data.url)
|
|
|
|
- this.curPostMap.Remove(data.url)
|
|
|
|
- callback(temp)
|
|
|
|
}
|
|
}
|
|
|
|
+ //请求成功移除缓存的消息请求
|
|
|
|
+ this.errPostMap.Remove(data.url)
|
|
|
|
+ this.curPostMap.Remove(data.url)
|
|
|
|
+ callback(temp)
|
|
|
|
+ }
|
|
// } catch (error) {
|
|
// } catch (error) {
|
|
// console.error("服务端回调数据处理时出现异常:", path, error)
|
|
// console.error("服务端回调数据处理时出现异常:", path, error)
|
|
// }
|
|
// }
|