|
@@ -72,7 +72,7 @@ export function useWs() {
|
|
|
let examId = `${parameter.project}_${item}`;
|
|
|
if (parameter.taskId) {
|
|
|
getTaskStarts(examId);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
getExamStarts(examId);
|
|
|
}
|
|
|
getNetWork(examId, (e: any) => {
|
|
@@ -110,9 +110,9 @@ export function useWs() {
|
|
|
let examId = parameter.examId;
|
|
|
if (parameter.taskId) {
|
|
|
getTaskStarts(examId);
|
|
|
- } else if(['skiprope','heartbeat'].includes(parameter.project)) {
|
|
|
+ } else if (['skiprope', 'heartbeat'].includes(parameter.project)) {
|
|
|
getDeviceStarts(examId);
|
|
|
- } else {
|
|
|
+ } else {
|
|
|
getExamStarts(examId);
|
|
|
}
|
|
|
getNetWork(examId, (e: any) => {
|
|
@@ -126,9 +126,10 @@ export function useWs() {
|
|
|
|
|
|
socket.on('msg2frontend', (e: any) => {
|
|
|
callback(e);
|
|
|
- if (['init_result', 'set_exam_state', 'exam_status', 'disconnect_request'].includes(e.cmd)) {
|
|
|
- console.log(`【接收:${e.cmd}】`, JSON.stringify(e));
|
|
|
- }
|
|
|
+ if (['init_result', 'set_exam_state', 'disconnect_request'].includes(e.cmd)) {
|
|
|
+ //心跳'exam_status'
|
|
|
+ console.log(`【接收:${e.cmd}】`, JSON.stringify(e));
|
|
|
+ }
|
|
|
//实时状态
|
|
|
if (e.cmd === 'exam_status') {
|
|
|
let index = examStateList.findIndex((item: any) => {
|
|
@@ -192,7 +193,7 @@ export function useWs() {
|
|
|
}
|
|
|
//状态变更
|
|
|
if (e.cmd === 'set_exam_state') {
|
|
|
-
|
|
|
+
|
|
|
// getClearExamStateTimer();
|
|
|
let index = examStateList.findIndex((item: any) => {
|
|
|
return item.examId == e.exam_id;
|
|
@@ -200,7 +201,7 @@ export function useWs() {
|
|
|
if (index != -1) {
|
|
|
examStateList[index].examState = e.data;
|
|
|
examStateList[index].wsStatus = e.status;
|
|
|
- PubSub.publish(e.exam_id, e);
|
|
|
+ PubSub.publish(`${e.exam_id}_${e.data}`, e);
|
|
|
}
|
|
|
if (e.data == 3) {
|
|
|
//关闭遮罩层
|
|
@@ -263,7 +264,8 @@ export function useWs() {
|
|
|
if (version == 'v2') {
|
|
|
type = type + '_' + version;
|
|
|
}
|
|
|
- if (['task_starts', 'exam_starts', 'msgfrom_frontend', 'exam_ends', 'get_exam_status', 'task_starts_v2', 'exam_starts_v2', 'msgfrom_frontend_v2', 'exam_ends_v2', 'get_exam_status_v2'].includes(type)) {
|
|
|
+ if (['task_starts', 'exam_starts', 'msgfrom_frontend', 'exam_ends', 'task_starts_v2', 'exam_starts_v2', 'msgfrom_frontend_v2', 'exam_ends_v2'].includes(type)) {
|
|
|
+ //这两个是心跳 'get_exam_status', 'get_exam_status_v2'
|
|
|
console.log(`【发送:${type}】`, JSON.stringify(data))
|
|
|
}
|
|
|
socket.emit(type, JSON.stringify(data), callback);
|
|
@@ -342,9 +344,8 @@ export function useWs() {
|
|
|
exam_id: examId
|
|
|
}
|
|
|
});
|
|
|
- PubSub.subscribe(examId, (eventName:any,res:any)=>{
|
|
|
- if(res.data == 40){
|
|
|
- PubSub.unsubscribe(examId);
|
|
|
+ PubSub.subscribe(`${examId}_40`, (eventName: any, res: any) => {
|
|
|
+ if (res.data == 40) {
|
|
|
resolve({ data: examStateList[index].examState });
|
|
|
}
|
|
|
});
|
|
@@ -366,9 +367,8 @@ export function useWs() {
|
|
|
exam_id: examId
|
|
|
}
|
|
|
});
|
|
|
- PubSub.subscribe(examId, (eventName:any,res:any)=>{
|
|
|
- if(res.data == 41){
|
|
|
- PubSub.unsubscribe(examId);
|
|
|
+ PubSub.subscribe(`${examId}_41`, (eventName: any, res: any) => {
|
|
|
+ if (res.data == 41) {
|
|
|
resolve({ data: examStateList[index].examState });
|
|
|
}
|
|
|
});
|
|
@@ -390,9 +390,8 @@ export function useWs() {
|
|
|
exam_id: examId
|
|
|
}
|
|
|
});
|
|
|
- PubSub.subscribe(examId, (eventName:any,res:any)=>{
|
|
|
- if(res.data == 43){
|
|
|
- PubSub.unsubscribe(examId);
|
|
|
+ PubSub.subscribe(`${examId}_43`, (eventName: any, res: any) => {
|
|
|
+ if (res.data == 43) {
|
|
|
resolve({ data: examStateList[index].examState });
|
|
|
}
|
|
|
});
|
|
@@ -466,9 +465,8 @@ export function useWs() {
|
|
|
exam_id: examId
|
|
|
}
|
|
|
});
|
|
|
- PubSub.subscribe(examId, (eventName:any,res:any)=>{
|
|
|
- if(res.data == 3){
|
|
|
- PubSub.unsubscribe(examId);
|
|
|
+ PubSub.subscribe(`${examId}_3`, (eventName: any, res: any) => {
|
|
|
+ if (res.data == 3) {
|
|
|
resolve({ data: examStateList[index].examState });
|
|
|
}
|
|
|
});
|
|
@@ -490,9 +488,8 @@ export function useWs() {
|
|
|
exam_id: examId
|
|
|
}
|
|
|
});
|
|
|
- PubSub.subscribe(examId, (eventName:any,res:any)=>{
|
|
|
- if(res.data == 3){
|
|
|
- PubSub.unsubscribe(examId);
|
|
|
+ PubSub.subscribe(`${examId}_3`, (eventName: any, res: any) => {
|
|
|
+ if (res.data == 3) {
|
|
|
resolve({ data: examStateList[index].examState });
|
|
|
}
|
|
|
});
|