Skip to content

Commit

Permalink
fix: await mqtt connected
Browse files Browse the repository at this point in the history
  • Loading branch information
sobird committed Feb 19, 2025
1 parent c83aaff commit d088cb3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ import { randomWave } from '@/utils/randomWave';
import MqttService from './services/MqttService';

const mqttService = new MqttService();
// 无需await
mqttService.start();
await mqttService.start();

const spinner = ora({
discardStdin: false,
Expand Down
2 changes: 1 addition & 1 deletion services/MqttService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export default class MqttService {
});
mqttClient.on('message', (topic, message) => {
const msg: MqttMessage = JSON.parse(message.toString());
console.log('message:', msg);
// console.log('message:', msg);

const method = this[msg.type as keyof MqttService] as (topic: string, message: MqttMessage) => void;
if (typeof method === 'function') {
Expand Down

0 comments on commit d088cb3

Please sign in to comment.