|
@@ -1,7 +1,7 @@
|
|
|
import store from "@/store";
|
|
|
import { Message } from "iview";
|
|
|
import { VUE_APP_WK_SERVER_SOCKET_FOR_AUDIO } from "@/constants/constants";
|
|
|
-import { createUserLog } from "@/utils/logger";
|
|
|
+import { createLog } from "@/utils/logger";
|
|
|
|
|
|
let ws;
|
|
|
let shouldReconnect = true;
|
|
@@ -13,7 +13,7 @@ let reconnectNumber = 0;
|
|
|
export function openWS({ examRecordDataId }) {
|
|
|
window._hmt.push(["_trackEvent", "websocket", "准备连接"]);
|
|
|
console.log("in openWS", examRecordDataId);
|
|
|
- createUserLog({ type: "websocket", action: "准备连接", examRecordDataId });
|
|
|
+ createLog({ type: "websocket", action: "准备连接", examRecordDataId });
|
|
|
ws = new WebSocket(
|
|
|
VUE_APP_WK_SERVER_SOCKET_FOR_AUDIO +
|
|
|
`?key=${store.state.user.key}&token=${store.state.user.token}`
|
|
@@ -27,7 +27,7 @@ export function openWS({ examRecordDataId }) {
|
|
|
|
|
|
ws.onclose = () => {
|
|
|
console.log("ws close by server");
|
|
|
- createUserLog({ type: "websocket", action: "ws close by server" });
|
|
|
+ createLog({ type: "websocket", action: "ws close by server" });
|
|
|
for (const heartbeatId of heartbeatIds) {
|
|
|
clearInterval(heartbeatId);
|
|
|
}
|
|
@@ -55,7 +55,7 @@ export function openWS({ examRecordDataId }) {
|
|
|
"websocket",
|
|
|
"连接被关闭后-准备连接",
|
|
|
]);
|
|
|
- createUserLog({
|
|
|
+ createLog({
|
|
|
type: "websocket",
|
|
|
action: "连接被关闭后-准备连接",
|
|
|
detail: "onclose",
|
|
@@ -88,7 +88,7 @@ export function openWS({ examRecordDataId }) {
|
|
|
}
|
|
|
if (location.href.includes("/order/")) {
|
|
|
window._hmt.push(["_trackEvent", "websocket", "连接错误后-重新连接"]);
|
|
|
- createUserLog({
|
|
|
+ createLog({
|
|
|
type: "websocket",
|
|
|
action: "连接被关闭后-准备连接",
|
|
|
detail: "onerror",
|
|
@@ -118,13 +118,13 @@ function heartbeat() {
|
|
|
}
|
|
|
|
|
|
export function closeWsWithoutReconnect() {
|
|
|
- createUserLog({ type: "websocket", action: "客户端准备关闭ws。" });
|
|
|
+ createLog({ type: "websocket", action: "客户端准备关闭ws。" });
|
|
|
shouldReconnect = false;
|
|
|
try {
|
|
|
if (ws && ws.readyState === 1) ws.close();
|
|
|
} catch (e) {
|
|
|
console.log("关闭ws异常。");
|
|
|
- createUserLog({ type: "websocket", action: "关闭ws异常。", detail: e });
|
|
|
+ createLog({ type: "websocket", action: "关闭ws异常。", detail: e });
|
|
|
}
|
|
|
}
|
|
|
|