Howto:COM Client use of myPBX

From innovaphone wiki
Revision as of 14:26, 27 April 2015 by Ckl (talk | contribs) (→‎Applies To)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Applies To

This information applies to

  • V10 innovaphone myPBX and later

The COM interface of myPBX can be used to start a call/chat via myPBX or to retrieve presence information for contacts.


More Information

Configuration

myPBX has to run.
We're using a C# sample, a COM client.

You can view the interfaces, enums etc. of myPBX with the OLE COM-Object Viewer (OleView.Exe) of the Microsoft Windows 7 SDK.
Open the myPBX.tlb of the myPBX installation folder:

  • IUCOfficeIntegration
  • IMessenger
  • IMessenger2
  • IMessenger3
  • IMessengerAdvanced
  • IMessengerContactResolution
  • IMessengerService
  • IMessengerServices
  • IMessengerContact
  • IMessengerContactAdvanced
  • IMessengerContacts

A description for these interfaces can be found here: http://msdn.microsoft.com/en-us/library/lync/bb758812%28v=office.14%29.aspx

Running the Sample Code

Create a C# console application and add the myPBX.exe as reference to the project.

If you do not want to reference myPBX.exe, you could create an own file interfaces.cs, where you copy&paste the interface definitions
of innovaphone.OfficeIntegration.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using innovaphone.OfficeIntegration;    // namespace of myPBX.exe
using System.Runtime.InteropServices;

namespace myPBXDial
{
    [ComImport, Guid(Guids.UCOfficeIntegrationClassId)]
    class UCOfficeIntegration
    {
    }

    class myPBXDial
    {
        static int Main(string[] args)
        {
            try
            {
                UCOfficeIntegration uc = new UCOfficeIntegration();
                IMessengerAdvanced iMsg = (IMessengerAdvanced)uc;
                object[] types = new object[1];
                types[0] = args[0];
                
                iMsg.StartConversation(CONVERSATION_TYPE.PHONE, types);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                return 2;
            }
            return 0;
        }
    }
}
?>

Explenation of the sample code

  • The class UCOfficeIntegration is a COM class wrapper, which is done with the ComImport statement. The GUID is retrieved from innovaphone.OfficeIntegration.
  • In the Main method you create an instance of this class and cast this instance to IMessengerAdvanced. On this object you can call all its interface methods.
  • Here we're starting a call with StartConversation.
  • If myPBX.exe is not running, you'll get an exception.

References