GuLiMmo
2024-08-27 1728006c7507dc973e684e0b03040304fa05e08a
src/mqtt/config.ts
@@ -1,8 +1,13 @@
import {
  IClientOptions,
} from 'mqtt'
const { mqttConfig: { clientId, username, password, host, protocol, port } } = window.globalApiConfig
/*
 * @Author: GuLiMmo 2820890765@qq.com
 * @Date: 2024-03-12 18:01:28
 * @LastEditors: GuLiMmo 2820890765@qq.com
 * @LastEditTime: 2024-08-27 16:17:01
 * @FilePath: /drone-web/src/mqtt/config.ts
 * @Description: mqtt配置
 * Copyright (c) 2024 by GuLiMmo, All Rights Reserved.
 */
import { IClientOptions } from 'mqtt'
export const OPTIONS: IClientOptions = {
  clean: true, // true: 清除会话, false: 保留会话
@@ -10,10 +15,11 @@
  resubscribe: true, // 断开重连后,再次订阅原订阅
  reconnectPeriod: 10000, // 重连间隔时间: 5s
  keepalive: 5, // 心跳间隔时间:1s
  clientId: clientId || 'DroneWeb',
  username: username || 'root',
  password: password || 'root',
  host: host || '139.196.74.78',
  protocol: protocol || 'ws',
  port: port || 8083,
  clientId: window?.globalApiConfig?.mqttConfig?.clientId || 'DroneWeb',
  username: window?.globalApiConfig?.mqttConfig?.username || 'root',
  password: window?.globalApiConfig?.mqttConfig?.password || 'root',
  host: window?.globalApiConfig?.mqttConfig?.host || '139.196.74.78',
  protocol: window?.globalApiConfig?.mqttConfig?.protocol || 'wss',
  // 8083
  port: window?.globalApiConfig?.mqttConfig?.port || 8084,
}