import { NgModule} from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { AppRoutingModule } from './app-routing.module'; import { AppComponent } from './app.component'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import {SharedModule} from "./shared/shared.module"; import {HttpClientModule} from "@angular/common/http"; import { ToastrModule } from 'ngx-toastr'; import { IMqttServiceOptions, MqttModule } from 'ngx-mqtt'; export const connection: IMqttServiceOptions = { hostname: 'test.mosquitto.org', port: 1883, clean: true, // 保留会话 connectTimeout: 4000, // 超时时间 reconnectPeriod: 4000, // 重连时间间隔 // 认证信息 clientId: 'pm-1720539453210', protocol: 'ws', connectOnCreate: false, } @NgModule({ declarations: [ AppComponent, ], imports: [ BrowserModule, AppRoutingModule, BrowserAnimationsModule, SharedModule, HttpClientModule, ToastrModule.forRoot({ maxOpened: 1, preventDuplicates: true, autoDismiss: true }), // ToastrModule added MqttModule.forRoot(connection) ], providers: [], bootstrap: [AppComponent] }) export class AppModule { }