-
Notifications
You must be signed in to change notification settings - Fork 1
/
Application.cs
40 lines (34 loc) · 1.13 KB
/
Application.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Options;
using NetfieldDeviceSample.Classes;
using NetfieldDeviceSample.Models;
namespace NetfieldDeviceSample
{
public class Application : IHostedService, IDisposable
{
private readonly IOptions<MqttConfig> _mqttconfig;
private MqttService mqttService {get; set;}
public SimulateData simulateData {get; private set;}
public Application(IOptions<MqttConfig> mqttConfig)
{
_mqttconfig = mqttConfig;
}
public async Task StartAsync(CancellationToken cancellationToken)
{
Console.WriteLine("Connect to MQTT Broker");
mqttService = new MqttService(_mqttconfig.Value.Server, _mqttconfig.Value.Port);
simulateData = new SimulateData(mqttService);
await DirectMethods.Init(simulateData);
}
public Task StopAsync(CancellationToken cancellationToken)
{
return Task.CompletedTask;
}
public void Dispose()
{
}
}
}