-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
44 lines (37 loc) · 1.21 KB
/
Program.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
41
42
43
44
using System;
using System.Net.Sockets;
using System.Threading;
using System.Threading.Tasks;
namespace UwpCompanion
{
class Program
{
static async Task Main(string[] args)
{
// Create MQTT client.
var mqttClient = new MqttClient("doranhome/pc/main/winmedia");
try
{
await mqttClient.Connect();
Console.WriteLine("Connected to MQTT.");
}
catch (ConnectivityError)
{
Console.WriteLine("Unable to connect to MQTT broker.");
}
Console.WriteLine("Initialize media.");
// Create media controls
var mediaControls = new MediaControls();
await mediaControls.Initialize();
// Create link between MQTT client and media controls.
var eventHandler = new MediaControlsEventHandler(mediaControls, mqttClient);
eventHandler.Initialize();
// Dumb infinite loop to keep application running while listening to events.
// TODO: Use a better approach.
while (true)
{
Thread.Sleep(10000);
}
}
}
}