| | |
| | | /* |
| | | * @Author: husq 931347610@qq.com |
| | | * @Date: 2023-08-22 09:55:39 |
| | | * @LastEditors: husq 931347610@qq.com |
| | | * @LastEditTime: 2023-09-19 10:23:42 |
| | | * @FilePath: \Cloud-API-Demo-Web\src\components\g-map\use-connect-mqtt.ts |
| | | * @Description: |
| | | * |
| | | * Copyright (c) 2023 by ${git_name_email}, All Rights Reserved. |
| | | */ |
| | | |
| | | import { |
| | | ref, |
| | | watch, |
| | |
| | | if (result?.code === 0) { |
| | | const { address, client_id, username, password, expire_time } = result.data |
| | | // @TODO: 校验 expire_time |
| | | mqttState.value = new UranusMqtt(address, { |
| | | clientId: client_id, |
| | | username, |
| | | password, |
| | | }) |
| | | mqttState.value = new UranusMqtt(address, {}) |
| | | mqttState.value?.initMqtt() |
| | | mqttState.value?.on('onStatus', (statusOptions: StatusOptions) => { |
| | | // @TODO: 异常case |
| | |
| | | reconnectPeriod: 10000, // 重连间隔时间: 5s |
| | | keepalive: 5, // 心跳间隔时间:1s |
| | | clientId: 'DroneWeb', |
| | | // username: 'root', |
| | | // password: 'root', |
| | | username: 'root', |
| | | password: 'root', |
| | | host: '182.106.212.58', |
| | | protocol: 'ws', |
| | | port: 35675, |