|
|
@ -1187,16 +1187,16 @@ export default { |
|
|
|
// websocket获取考核及竞赛信息,用于自动提交 |
|
|
|
// websocket获取考核及竞赛信息,用于自动提交 |
|
|
|
// socket连接成功 |
|
|
|
// socket连接成功 |
|
|
|
open () { |
|
|
|
open () { |
|
|
|
console.log("socket连接成功"); |
|
|
|
// console.log("socket连接成功"); |
|
|
|
}, |
|
|
|
}, |
|
|
|
// socket连接失败 |
|
|
|
// socket连接失败 |
|
|
|
error () { |
|
|
|
error () { |
|
|
|
console.log("连接错误"); |
|
|
|
// console.log("连接错误"); |
|
|
|
}, |
|
|
|
}, |
|
|
|
// 接收消息 |
|
|
|
// 接收消息 |
|
|
|
getMessage (msg) { |
|
|
|
getMessage (msg) { |
|
|
|
console.log("==websocket接收数据=="); |
|
|
|
// console.log("==websocket接收数据=="); |
|
|
|
console.log(JSON.parse(msg.data)); |
|
|
|
// console.log(JSON.parse(msg.data)); |
|
|
|
const { content } = JSON.parse(msg.data) |
|
|
|
const { content } = JSON.parse(msg.data) |
|
|
|
// 1赛事、2创业、3考核、4模型。-号拼接携带id |
|
|
|
// 1赛事、2创业、3考核、4模型。-号拼接携带id |
|
|
|
if (content == 1 && this.projectPermissions === 2) { |
|
|
|
if (content == 1 && this.projectPermissions === 2) { |
|
|
@ -1207,7 +1207,7 @@ export default { |
|
|
|
}, |
|
|
|
}, |
|
|
|
// 关闭socket |
|
|
|
// 关闭socket |
|
|
|
close () { |
|
|
|
close () { |
|
|
|
console.log("socket已经关闭"); |
|
|
|
// console.log("socket已经关闭"); |
|
|
|
}, |
|
|
|
}, |
|
|
|
// 初始化socket |
|
|
|
// 初始化socket |
|
|
|
initSocket ({ id, account }) { |
|
|
|
initSocket ({ id, account }) { |
|
|
@ -1227,6 +1227,8 @@ export default { |
|
|
|
// let ws = new WebSocket(`ws://124.71.74.9:15674/ws`); |
|
|
|
// let ws = new WebSocket(`ws://124.71.74.9:15674/ws`); |
|
|
|
let ws = new WebSocket(`wss://python.occupationlab.com/ws`); |
|
|
|
let ws = new WebSocket(`wss://python.occupationlab.com/ws`); |
|
|
|
this.client = Stomp.over(ws); |
|
|
|
this.client = Stomp.over(ws); |
|
|
|
|
|
|
|
this.client.heartbeat.outgoing = 0 |
|
|
|
|
|
|
|
this.client.heartbeat.incoming = 0 |
|
|
|
//初始化连接 |
|
|
|
//初始化连接 |
|
|
|
const headers = { |
|
|
|
const headers = { |
|
|
|
login: MQTT_USERNAME, |
|
|
|
login: MQTT_USERNAME, |
|
|
@ -1235,17 +1237,18 @@ export default { |
|
|
|
//进行连接 |
|
|
|
//进行连接 |
|
|
|
this.client.connect(headers.login, headers.passcode, this.onConnected, this.onFailed, 'pyhost'); |
|
|
|
this.client.connect(headers.login, headers.passcode, this.onConnected, this.onFailed, 'pyhost'); |
|
|
|
}, |
|
|
|
}, |
|
|
|
onConnected: function () { |
|
|
|
onConnected () { |
|
|
|
//订阅频道 |
|
|
|
//订阅频道 |
|
|
|
this.clientTopic = '/amq/queue/pythonQueue_' + this.accountId; |
|
|
|
this.clientTopic = '/amq/queue/pythonQueue_' + this.accountId; |
|
|
|
this.client.subscribe(this.clientTopic, this.responseCallback, this.onFailed); |
|
|
|
this.client.subscribe(this.clientTopic, this.responseCallback, this.onFailed); |
|
|
|
}, |
|
|
|
}, |
|
|
|
onFailed: function (frame) { |
|
|
|
onFailed (frame) { |
|
|
|
console.log("MQ Failed: " + frame); |
|
|
|
console.log("MQ Failed: " + frame); |
|
|
|
// this.$message.error('连接失败') |
|
|
|
// this.client.reset().start(); |
|
|
|
|
|
|
|
this.connect() |
|
|
|
}, |
|
|
|
}, |
|
|
|
// 回传消息 |
|
|
|
// 回传消息 |
|
|
|
responseCallback: function (frame) { |
|
|
|
responseCallback (frame) { |
|
|
|
const data = JSON.parse(frame.body) |
|
|
|
const data = JSON.parse(frame.body) |
|
|
|
|
|
|
|
|
|
|
|
console.log("接收信息:", data, typeof data, newmain, newmain.$emit); |
|
|
|
console.log("接收信息:", data, typeof data, newmain, newmain.$emit); |
|
|
@ -1262,7 +1265,7 @@ export default { |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
// 断开相应的连接 |
|
|
|
// 断开相应的连接 |
|
|
|
close: function () { |
|
|
|
close () { |
|
|
|
this.client.disconnect(function () { |
|
|
|
this.client.disconnect(function () { |
|
|
|
console.log("已退出账号"); |
|
|
|
console.log("已退出账号"); |
|
|
|
}) |
|
|
|
}) |
|
|
@ -1271,7 +1274,7 @@ export default { |
|
|
|
// 心跳检测 |
|
|
|
// 心跳检测 |
|
|
|
heartbeatDetection () { |
|
|
|
heartbeatDetection () { |
|
|
|
setInterval(async () => { |
|
|
|
setInterval(async () => { |
|
|
|
await this.$get(this.api.heartbeatDetectionRabbit) |
|
|
|
// await this.$get(this.api.heartbeatDetectionRabbit) |
|
|
|
await this.$get(this.api.heartbeatDetection) |
|
|
|
await this.$get(this.api.heartbeatDetection) |
|
|
|
}, 55 * 1000) |
|
|
|
}, 55 * 1000) |
|
|
|
}, |
|
|
|
}, |
|
|
|