Reputation: 11
We have a telephony scenario where a group of 5 emergency devices are all called at the same time in a group pickup configuration. There is a generic number which is called and then rings all the 5 devices, leaving to the operators the choice of what device will pickup the call.
The problem is: when a call is picked up in this scenario, I can't see the CALL_STATE.CS_CONNECTED event being fired. This event is being fired when I call directly any of the 5 extensions, but not when a group pickup occurs.
I'm using the Interop.TAPI3Lib.dll in a windows service application, here goes a piece of code that succesfully notifies the CALL_STATE.CS_CONNECTED event when I call the extensions directly:
public class MyClass
{
private TAPI _clTapi;
public ITTAPI gobjTapi1;
public ITAddress[] gobjAddress1;
public ITCallInfo gCall;
public ITCallHub gHub;
public ITCollection objCollAddresses;
private ITCallStateEvent CallStateObject;
//Service start/stop/abort routines goes here
private void TapiEvents(TAPI_EVENT TapiEvent, object pEvent)
{
if (TapiEvent == TAPI_EVENT.TE_CALLSTATE)
{
Thread thread = new Thread(new ThreadStart(this.CallStateEvent));
this.CallStateObject = (ITCallStateEvent)pEvent;
thread.Start();
}
}
private void CallStateEvent()
{
CALL_STATE state = this.CallStateObject.Call.CallState;
if (state == CALL_STATE.CS_CONNECTED)
{
//Do something...
}
else if (state == CALL_STATE.CS_DISCONNECTED)
{
//Do something...
}
}
}
My question is: is there any specific treatment when dealing with pickup/connection events in group pickups?
Upvotes: 0
Views: 47
Reputation: 11
After some more tests, I found out that the problem was a thread concurrency between simultaneous CS_CONNECTED and CS_DISCONNECTED events. In this scenario, a call answer generates 1 connected event and N-1 disconnected events, where N is the number of devices being called.
Since there was only one CallStateObject to store call information, the threads were unsafely using this object at the same time and therefore "mixing" each other event values. Just by dealing with this concurrency problem, the problem was solved.
Upvotes: 1