update:新增比赛服断线重连机制
This commit is contained in:
+18
@@ -80,6 +80,10 @@
|
||||
// audioManager.play("射箭声音")
|
||||
}
|
||||
|
||||
function onNetworkStatusChange(status) {
|
||||
matchWebsocket.handleMatchNetworkStatusChange(status);
|
||||
}
|
||||
|
||||
function connectMatchServerFromMessage(content) {
|
||||
const messages = Array.isArray(content) ? content : [content];
|
||||
messages.forEach((message) => {
|
||||
@@ -108,6 +112,17 @@
|
||||
uni.$on("update-online", emitUpdateOnline);
|
||||
uni.$on("session-kicked-out", onSessionKickedOut);
|
||||
uni.$on("device-bind-invalid", onDeviceBindInvalid);
|
||||
if (typeof uni.offNetworkStatusChange === "function") {
|
||||
uni.offNetworkStatusChange(onNetworkStatusChange);
|
||||
}
|
||||
if (typeof uni.onNetworkStatusChange === "function") {
|
||||
uni.onNetworkStatusChange(onNetworkStatusChange);
|
||||
}
|
||||
if (typeof uni.getNetworkType === "function") {
|
||||
uni.getNetworkType({
|
||||
success: onNetworkStatusChange
|
||||
});
|
||||
}
|
||||
const token = uni.getStorageSync(
|
||||
`${uni.getAccountInfoSync().miniProgram.envVersion}_token`
|
||||
);
|
||||
@@ -122,6 +137,9 @@
|
||||
uni.$off("update-online", emitUpdateOnline);
|
||||
uni.$off("session-kicked-out", onSessionKickedOut);
|
||||
uni.$off("device-bind-invalid", onDeviceBindInvalid);
|
||||
if (typeof uni.offNetworkStatusChange === "function") {
|
||||
uni.offNetworkStatusChange(onNetworkStatusChange);
|
||||
}
|
||||
matchWebsocket.closeMatchWebSocket({
|
||||
reason: "app-hide"
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user