Example Application

The example allows you to test the Altitude SIP Phone.

To build a desktop application using the Integration Server .NET API, you need Microsoft Visual Studio.

After creating a new solution in Visual Studio, add the following required DLL references to your project that are the DLLs providing the .NET API:

  • Altitude.ASTools.Config.dll
  • Altitude.ASTools.Tracer.dll
  • Altitude.IntegrationServer.DotNetApi.dll
  • Altitude.IntegrationServer.IDotNetApi.dll
  • Altitude.IntegrationServer.Events.dll
  • Altitude.IntegrationServer.Exceptions.dll
  • Altitude.IntegrationServer.Types.dll
  • Altitude.IntegrationServer.Utils.dll

Caution

Ensure you use an update level compatible with the Integration Server.

The following example logs an agent to Altitude as follows:

  • Creates an Integration Server reference.
  • Invokes the Login method using the agent user name and password, and retrieves a reference to an Instance object.
  • Gets the LoggedAgent from the Instance object.
  • Executes the SetLoginContext operation on the agent object.
  • Sets the extension.

try

{

      IS = Altitude.IntegrationServer.DotNetApi.IntegrationServerManager.GetIntegrationServer() as Altitude.IntegrationServer.DotNetApi.IntegrationServer;

      //Login and set extension

      IS_Instance = (Instance)IS.Login(instance, false, agent, Altitude.IntegrationServer.Types.AuthenticationType.Uci, password, "", "", false);

      IS_Agent = (Agent)IS_Instance.LoggedAgent;

      IS_Agent.IncomingSessionEvent += IS_Agent_IncomingSessionEvent;

      IS_Agent.SetLoginContext(site,"");

      IS_Agent.ExtensionChangedEvent += new IntegrationServer.IDotNetApi.ISEventHandler<IntegrationServer.IDotNetApi.IAgent, ExtensionChangedEvent>(IS_Agent_ExtensionChangedEvent);

      IS_Agent.SetExtension(extension);

      //Register relevant event handlers

      IS_Agent.IncomingSessionEvent += IS_Agent_ClientCreatedSessionEvent;

      IS_Instance.LogoutEvent += IS_Agent_AgentLogoutEvent;

      IS_Agent.ExtensionClearedEvent += IS_Agent_ExtensionClearedEvent;

}

catch (Exception ex)

{

  (...)

}

When the SetExtension method is invoked, the Altitude SIP Phone must be already running and logged to Altitude.

To start the Altitude SIP Phone, you can use the following code:

Process p = null;

try

{

      p = new Process();

      p.StartInfo = new ProcessStartInfo(@"Path\To\Altitude.SIPPhone.exe", agent);

      p.StartInfo.UseShellExecute = false;

      p.SartInfo.RedirectStandardOutput = false;

      p.Start();

}

catch (Exception ex)

{

      Console.WriteLine("Exception creating softphone app: {0}\n{1}", ex.Message, ex.StackTrace);

      return;

}

The following example displays how to launch the Altitude SIP Phone with program commands that send arguments for user, password, and instance:

 Process p = null;

 try

 {

      p = new Process();

      p.StartInfo = new ProcessStartInfo(

          @"path\to\Altitude.SIPPhone.exe",

                  string.Format("/u {0} /p {1} /i {2}", agent, password, instance));

      p.StartInfo.UseShellExecute = false;

      p.StartInfo.RedirectStandardOutput = false;

      p.Start();

 }

 catch (Exception ex)

 {

      Console.WriteLine("Exception creating softphone app: {0}\n{1}", ex.Message, ex.StackTrace);

      return;

 }

Closing the application

Use the ExitOnLogout parameter to configure the Altitude SIP Phone to exit whenever the agent logs out or if the instance is set offline.

You can also make the desktop application close the Altitude SIP Phone by sending a WM_CLOSE message to the Altitude SIP Phone.