-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
73 lines (62 loc) · 3.2 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
using System.Reactive.Linq;
using Jabra.NET.Sdk.Core;
using Jabra.NET.Sdk.Core.Types;
using Jabra.NET.Sdk.Properties;
internal class Program
{
public static async Task Main()
{
Console.WriteLine("Jabra .NET SDK Device Settings Sample app starting. Press ctrl+c or close the window to end.\n");
//Initialize the core SDK. Recommended to use Init.InitManualSdk(...) (not Init.Init(...)) to allow setup of listeners before the SDK starts discovering devices.
var config = new Config(
partnerKey: "get-partner-key-at-developer.jabra.com",
appId: "JabraDotNETSettingsSample",
appName: "Jabra .NET Settings Sample"
);
IManualApi jabraSdk = Init.InitManualSdk(config);
//Subscribe to SDK log events.
jabraSdk.LogEvents.Subscribe((log) =>
{
if (log.Level == LogLevel.Error) Console.WriteLine(log.ToString());
//Ignore info, warning, and debug log messages.
});
//Initialize the SDK's properties module
IPropertyModule jabraSdkProps = new PropertyModule(jabraSdk);
IPropertyFactory jabraSdkPropsFactory = await jabraSdkProps.CreatePropertyFactory();
//Setup listeners for Jabra devices being attached/detected.
SetupDeviceListeners(jabraSdk, jabraSdkPropsFactory);
// Enable the SDK's device discovery AFTER listeners and other necessary infrastructure is setup.
await jabraSdk.Start();
Console.WriteLine("Now listening for Jabra devices...\n");
//Keep the sample app running until actively closed.
Task.Delay(-1).Wait();
}
static void SetupDeviceListeners(IApi jabraSdk, IPropertyFactory jabraSdkPropsFactory)
{
//Subscribe to Jabra devices being attached/detected by the SDK
jabraSdk.DeviceAdded.Subscribe((IDevice device) =>
{
Console.WriteLine($"> Device attached/detected: {device.Name} (Product ID: {device.ProductId}, Serial #: {device.SerialNumber})");
//Determine which sample to run based on the device detected.
switch (device.Name)
{
case "Jabra PanaCast 50":
Console.WriteLine("\tPress '1': To write settings requiring the device to reboot.\n\tPress any other key to read, write and observe properties not requiring device reboot.\nAwaiting your input...");
var userSelection = Console.ReadKey(intercept: true);
if (userSelection.KeyChar == '1')
SampleForJabraPanacast50.ReadWriteWithReboot(device, jabraSdkPropsFactory);
else
SampleForJabraPanacast50.ReadWriteObserve(device, jabraSdkPropsFactory);
break;
case "Jabra Engage 50 II":
SampleForJabraEngage50II.ReadWriteObserve(device, jabraSdkPropsFactory);
break;
}
});
//Subscribe to Jabra devices being detached/rebooted
jabraSdk.DeviceRemoved.Subscribe((IDevice device) =>
{
Console.WriteLine($"< Device detached/reboots: {device.Name} (Product ID: {device.ProductId}, Serial #: {device.SerialNumber})");
});
}
}