3 Initializing the core module

The Jabra library uses a modular architecture, consisting of a core module and two modules offering call control capabilities. The core module handles low-level communication with Jabra devices, while the ECC and ACC modules provide call control for your application.

Due to a direct dependency between the modules and the core module, you must first initialize the core module before creating instances of any of the call control modules.

3.1 Initializing the core module for web applications

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. See the following code snippet:

using Jabra.NET.Sdk.Core;

internal static class Program
{
    static void Main()
    {
        // Initialize Jabra library without any configuration

        var jabraCore = Init.InitSdk();

        // Proceed to use the Jabra library
    }
}

3.2 Configuring 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 partner support.

See the following code sample.

// Obtain your Partner Key from the Developer Zone
var config = new Config(
    partnerKey: "0123-456789ab-cdef-0123-4567-89abcdef0123",
    appId: "my-app",
    appName: "My App"
);

3.2.1 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(
    // Partner key - obtain this from the Developer Zone
    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. Generating a Partner Key is necessary in the case that you need support from Jabra

You can generate an organization or company-wide key that applies to all your applications from the My Partner Keys page in the Jabra Developer Zone.

3.2.2 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.

var jabraCore = Init.InitSdk();

jabraCore.LogEvents.Subscribe((log) =>
{
    if (log.Level == LogLevel.ERROR)
    {
        Console.WriteLine(log.ToString());
    }
    // Ignore messages with other log levels
});

For more information about ILogger, LogEvent, StackLayer and LogLevel see the Jabra .NET API Reference page.

3.2.3 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 Zone
var config = new Config(
    partnerKey: "0123-456789ab-cdef-0123-4567-89abcdef0123",
    appId: "my-app",
    appName: "My App"
);

var jabraCore = Init.InitSdk(config);

3.3 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 (see chapter on Call Control)
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.SDK_USAGE_ERROR)
    {
        messageToUser = "The device is used by another application";
    }
    Console.WriteLine(messageToUser);
}