update:新增比赛服链接
This commit is contained in:
+26
@@ -7,9 +7,13 @@
|
||||
onHide
|
||||
} from "@dcloudio/uni-app";
|
||||
import websocket from "@/websocket";
|
||||
import matchWebsocket from "@/matchWebsocket";
|
||||
import {
|
||||
getDeviceBatteryAPI
|
||||
} from "@/apis";
|
||||
import {
|
||||
MESSAGETYPES
|
||||
} from "@/constants";
|
||||
import useStore from "@/store";
|
||||
import {
|
||||
storeToRefs
|
||||
@@ -36,6 +40,9 @@
|
||||
websocket.createWebSocket(token, onShootWsMsg);
|
||||
}
|
||||
if (!newVal) {
|
||||
matchWebsocket.closeMatchWebSocket({
|
||||
reason: "logout"
|
||||
});
|
||||
websocket.closeWebSocket();
|
||||
}
|
||||
}, {
|
||||
@@ -73,10 +80,26 @@
|
||||
// audioManager.play("射箭声音")
|
||||
}
|
||||
|
||||
function connectMatchServerFromMessage(content) {
|
||||
const messages = Array.isArray(content) ? content : [content];
|
||||
messages.forEach((message) => {
|
||||
if (
|
||||
message?.constructor ===
|
||||
MESSAGETYPES.ShootSyncBattleCreateMatchLinkID
|
||||
) {
|
||||
matchWebsocket.connectMatchWebSocketFromNotice(
|
||||
message,
|
||||
user.value.id
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function onShootWsMsg(content) {
|
||||
if(content.type === 'shoot-trigger'){
|
||||
onDeviceShoot()
|
||||
}
|
||||
connectMatchServerFromMessage(content);
|
||||
uni.$emit("socket-inbox", content);
|
||||
}
|
||||
|
||||
@@ -99,6 +122,9 @@
|
||||
uni.$off("update-online", emitUpdateOnline);
|
||||
uni.$off("session-kicked-out", onSessionKickedOut);
|
||||
uni.$off("device-bind-invalid", onDeviceBindInvalid);
|
||||
matchWebsocket.closeMatchWebSocket({
|
||||
reason: "app-hide"
|
||||
});
|
||||
websocket.closeWebSocket();
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user