Author: Lewis Collins, Plantronics

When using the Plantronics COM API how do you ensure the connection to the Plantronics Hub software is working?
  • What if the user accidentally shuts down Plantronics Hub (or it crashes), or user upgrades it which would also result in it shutting down and starting again. Would your software re-connect to the COM API automatically?
  • What if Plantronics Hub is not installed, will your software still attempt to connect to it, resulting in long COM timeout? (Will this timeout impact your applications performance)?
On this page I present a solution to these problems that ensures resilience of connection to Plantronics COM API covering the scenarios mentioned above.

The approach is as follows:
  1. Move all the code that connects / interacts with Plantronics COM API into a seperate class with its own thread. Now Plantronics COM API interaction is done on its own thread it will not impact your application's performance even if a COM timeout / exception occurs. This class is called HubSDKConnector.
  2. In HubSDKConnector add a watchdog timer that polls (attempts to use) the COM API every 5 seconds. If the connection fails (exception occurs) it will attempt to re-establish connection. Note, this interval is slowed to 60 seconds if HubSDKConnector detects that a Plantronics Hub upgrade is in progress (Hub installer is running). This corner case allows user to upgrade Hub without your application attempting to request COM API again, which would respawn the Hub EXE before install operation completes, therefore requiring a reboot to complete install - this is not desirable
enlightened Code for this sample: click here>> (note: you must be registered and signed in to access this).

The code is functionally the same is as the basic C# sample (in Get Started, C# Tab), with the integration code moved into HubSDKConnector.cs. The code is in C#, but the same concept could be implemented in C++ with the Plantronics COM API.

Here is a screenshot of it running.

What do you think of this solution? Let me know your feedback or questions using the form at the bottom of the page. Have fun! :-)
Lewis.