Initializing the core module
The .NET library_ uses a modular architecture, consisting of a core module and two modules offering call control capabilities.
These are:
- Call Control
- Easy Call Control
The core module handles low-level communication with Jabra devices. Call Control and Easy Call Control provide call control for your application.
You must initialize the core module before creating instances for Call Control or Easy Call Control.
Initialize the core module
Following the installation of the NuGet package, you must initialize the library.
You can do this via the Jabra.NET.Sdk.Core.Init.InitSdk
static´function:
using Jabra.NET.Sdk.Core;
internal static class Program
{
static void Main()
{
// Initialize Jabra library without any configuration
IApi jabraCore = Init.InitSdk();
// Proceed to use the Jabra library
}
}
Configure the core module
This section elaborates on configuring the core module by passing an instance of the Config
interface when initializing the Jabra library.
To help you with the configuration, each sub-section contains code snippets showing configuration options.
For example, you can provide an identifier and a name for your application and integrate these with a Partner Key to register your application with Jabra for developer support.
See the following code sample:
// Obtain your Partner Key from the developer.jabra.com
Config config = new Config(
partnerKey: "0123-456789ab-cdef-0123-4567-89abcdef0123",
appId: "my-app",
appName: "My App"
);
Identifying and registering your application
To uniquely identify your application and display it properly to end
users, you must configure the PartnerKey
, AppId
, and AppName
properties.
The PartnerKey
, AppId
and AppName
fields let you register your
application with Jabra Direct, empowering the end-user to choose their
application as their preferred softphone. In turn, the Jabra library
uses it to filter out messages not intended for your application.
Naming your application
The AppName
is an end-user friendly name for your application. Your app
name consists of a string with a minimum of three characters. It may
contain a combination of letters (A-Z, a-z), numbers (123), hyphens (-),
whitespaces ( ), or ampersands (&). The name is restricted to 100
characters (100 bytes in UTF-8) and must begin with a letter or number.
On the other hand, an app identifier or AppId
consists of a string
between three and 100 characters (maximum of 100 bytes in UTF-8). It may
contain a combination of letters (A-Z, a-z), numbers (123), underscores
(_), or hyphens (-).
See the following code snippet:
Config config = new Config(
// Your Partner Key from developer.jabra.com
partnerKey: "0123-456789ab-cdef-0123-4567-89abcdef0123",
// Application ID
appId: "my-app",
// Application Name
appName: "My App"
);
Generating a Partner Key
As best practice, it is suggested that you initialize the core module with a Partner Key.
You can generate an organization or company-wide key that applies to all your applications from the Partner Key page in the member area of Jabra Developer Zone.
Setting the library logging
To receive a logging message from the library in your application, the
IApi
interface exposes an observable LogEvents
which you can subscribe
to, as illustrated in the following code sample.
IApi jabraCore = Init.InitSdk();
jabraCore.LogEvents.Subscribe((log) =>
{
if (log.Level == LogLevel.Error)
{
Debug.WriteLine(log.ToString());
}
// Ignore messages with other log levels
});
Configuring the core library
To configure the core module with all Config
parameters, see the
following code sample.
// Obtain your Partner Key from the developer.jabra.com
Config config = new Config(
partnerKey: "0123-456789ab-cdef-0123-4567-89abcdef0123",
appId: "my-app",
appName: "My App"
);
IApi jabraCore = Init.InitSdk(config);
Error handling
To provide more details about the type of error that occurred, a custom
JabraException
class is used.
The following code sample shows how you can inform the end-user if they try to use a functionality not available on their Jabra device:
// Assuming creation of call control instance
try
{
await callControl.TakeCallLock();
// This will throw if another application has already locked the device
}
catch (JabraException ex)
{
var messageToUser = "An unknown error happened";
if (ex.Type == ErrorType.SdkUsageError)
{
messageToUser = "The device is used by another application";
}
Debug.WriteLine(messageToUser);
}