无人机及机场直播不稳定问题;多组件同时连接mqtt但是mqtt方法异步导致连接冲突一直重连问题修改
parent
a35729307d
commit
dc728a4c0f
|
|
@ -6,6 +6,7 @@ import { timestampToFormattedDate } from '@/utils/index';
|
||||||
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const userInfo = userStore.getUserInfo;
|
const userInfo = userStore.getUserInfo;
|
||||||
|
let connectLock = false
|
||||||
|
|
||||||
const { createMessage } = useMessage();
|
const { createMessage } = useMessage();
|
||||||
const seizeClientId = 'mqtt_client_1581F8HGX254V00A0BUY_seize';
|
const seizeClientId = 'mqtt_client_1581F8HGX254V00A0BUY_seize';
|
||||||
|
|
@ -55,6 +56,21 @@ const createConnection = (callback?) => {
|
||||||
// 连接mqtt的时候,先用GetRedisUser查一下有没有,
|
// 连接mqtt的时候,先用GetRedisUser查一下有没有,
|
||||||
// 然后AddOrUpdateRedisUser更新或添加,
|
// 然后AddOrUpdateRedisUser更新或添加,
|
||||||
// 控制的时候先查一下有没有锁定的用户GetLockedClients
|
// 控制的时候先查一下有没有锁定的用户GetLockedClients
|
||||||
|
if(connectLock){
|
||||||
|
if (callback) {
|
||||||
|
if(client && client.connected){
|
||||||
|
callback();
|
||||||
|
}else{
|
||||||
|
setTimeout(() => {
|
||||||
|
client.on('connect', () => {
|
||||||
|
callback();
|
||||||
|
});
|
||||||
|
}, 3000)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
connectLock = true
|
||||||
try {
|
try {
|
||||||
getRedisUser(userInfo.id).then((res) => {
|
getRedisUser(userInfo.id).then((res) => {
|
||||||
console.log("getRedisUser",res);
|
console.log("getRedisUser",res);
|
||||||
|
|
@ -120,7 +136,7 @@ const destroyConnection = () => {
|
||||||
};
|
};
|
||||||
// 订阅事件
|
// 订阅事件
|
||||||
const clientSubscribe = (topic: string, options?: any) => {
|
const clientSubscribe = (topic: string, options?: any) => {
|
||||||
if(!topic){
|
if(topic.includes('/null/')){
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// if (!client || !client.connected) {
|
// if (!client || !client.connected) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue