You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.2KB

  1. import { NgModule} from '@angular/core';
  2. import { BrowserModule } from '@angular/platform-browser';
  3. import { AppRoutingModule } from './app-routing.module';
  4. import { AppComponent } from './app.component';
  5. import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
  6. import {SharedModule} from "./shared/shared.module";
  7. import {HttpClientModule} from "@angular/common/http";
  8. import { ToastrModule } from 'ngx-toastr';
  9. import { IMqttServiceOptions, MqttModule } from 'ngx-mqtt';
  10. export const connection: IMqttServiceOptions = {
  11. hostname: 'test.mosquitto.org',
  12. port: 1883,
  13. clean: true, // 保留会话
  14. connectTimeout: 4000, // 超时时间
  15. reconnectPeriod: 4000, // 重连时间间隔
  16. // 认证信息
  17. clientId: 'pm-1720539453210',
  18. protocol: 'ws',
  19. connectOnCreate: false,
  20. }
  21. @NgModule({
  22. declarations: [
  23. AppComponent,
  24. ],
  25. imports: [
  26. BrowserModule,
  27. AppRoutingModule,
  28. BrowserAnimationsModule,
  29. SharedModule,
  30. HttpClientModule,
  31. ToastrModule.forRoot({
  32. maxOpened: 1,
  33. preventDuplicates: true,
  34. autoDismiss: true
  35. }), // ToastrModule added
  36. MqttModule.forRoot(connection)
  37. ],
  38. providers: [],
  39. bootstrap: [AppComponent]
  40. })
  41. export class AppModule { }