|
@@ -10,6 +10,7 @@ const HEARTBEAT_INTERVAL = 50 * 1000;
|
|
|
let reconnectNumber = 0;
|
|
|
|
|
|
export function openWS({ examRecordDataId }) {
|
|
|
+ window._hmt.push(["_trackEvent", "websocket", "准备连接"]);
|
|
|
console.log("in openWS", examRecordDataId);
|
|
|
try {
|
|
|
ws = new WebSocket(
|
|
@@ -21,12 +22,14 @@ export function openWS({ examRecordDataId }) {
|
|
|
// tryWSReconnect();
|
|
|
reconnectNumber++;
|
|
|
if (reconnectNumber >= 5) {
|
|
|
+ reconnectNumber = 0;
|
|
|
Message.error({
|
|
|
content: "Websocket重连失败",
|
|
|
duration: 5,
|
|
|
closable: true
|
|
|
});
|
|
|
}
|
|
|
+ window._hmt.push(["_trackEvent", "websocket", "初始连接-连接失败"]);
|
|
|
openWS({ examRecordDataId });
|
|
|
}, RECONNECT_INTERVAL);
|
|
|
return;
|
|
@@ -47,12 +50,18 @@ export function openWS({ examRecordDataId }) {
|
|
|
// tryWSReconnect();
|
|
|
reconnectNumber++;
|
|
|
if (reconnectNumber >= 5) {
|
|
|
+ reconnectNumber = 0;
|
|
|
Message.error({
|
|
|
content: "Websocket重连失败",
|
|
|
duration: 5,
|
|
|
closable: true
|
|
|
});
|
|
|
}
|
|
|
+ window._hmt.push([
|
|
|
+ "_trackEvent",
|
|
|
+ "websocket",
|
|
|
+ "连接被关闭后-准备连接"
|
|
|
+ ]);
|
|
|
openWS({ examRecordDataId });
|
|
|
}, RECONNECT_INTERVAL);
|
|
|
} else {
|
|
@@ -115,6 +124,7 @@ function processWSMessage(event) {
|
|
|
break;
|
|
|
case "GET_QR_CODE":
|
|
|
console.log("get qrcode", res);
|
|
|
+ window._hmt.push(["_trackEvent", "websocket", "获得二维码"]);
|
|
|
store.commit("examingHomeModule/setQuestionQrCode", {
|
|
|
qrCode: res.data.qrCode,
|
|
|
order: res.data.order
|
|
@@ -122,12 +132,14 @@ function processWSMessage(event) {
|
|
|
break;
|
|
|
case "SCAN_QR_CODE":
|
|
|
console.log("wx scanned qrcode", res);
|
|
|
+ window._hmt.push(["_trackEvent", "websocket", "二维码被扫描"]);
|
|
|
store.commit("examingHomeModule/setQuestionQrCodeScanned", {
|
|
|
order: res.data.order
|
|
|
});
|
|
|
break;
|
|
|
case "GET_AUDIO_ANSWER":
|
|
|
console.log("get audio url", res);
|
|
|
+ window._hmt.push(["_trackEvent", "websocket", "获得音频地址"]);
|
|
|
store.commit("examingHomeModule/setQuestionAudioFileUrl", {
|
|
|
order: res.data.order,
|
|
|
audioFileUrl: res.data.audioFileUrl
|