示例#1
0
        private void MainThread_OnCallStatus(BriaAPI.CallStatusEventArgs args)
        {
            Boolean[] lineInUse = new Boolean[6];

            List <BriaAPI.Call> callList = args.CallList;

            foreach (BriaAPI.Call call in callList)
            {
                Boolean   existingCall = false;
                PhoneLine phoneLine    = null;

                // Check if the call was previously in the list
                for (int i = 0; i < 6; i++)
                {
                    phoneLine = phoneLines[i];

                    if ((phoneLine != null) && (phoneLine.Id == call.CallId))
                    {
                        phoneLine.RemoteParties.Clear();

                        lineInUse[i] = true;
                        existingCall = true;
                        break;
                    }
                }

                // If the call is not already existing, we have to add as new call
                if (!existingCall)
                {
                    PhoneLine newPhoneLine = new PhoneLine(call.CallId);
                    phoneLine = newPhoneLine;

                    // Find empty slot to put it in
                    for (int i = 0; i < 6; i++)
                    {
                        if (phoneLines[i] == null)
                        {
                            phoneLines[i] = phoneLine;
                            lineInUse[i]  = true;
                            break;
                        }
                    }
                }

                // And fill in the information
                phoneLine.HoldState = call.HoldState;

                foreach (BriaAPI.CallParticipant participant in call.ParticipantList)
                {
                    RemoteParty remoteParty = new RemoteParty();
                    remoteParty.Number        = participant.Number;
                    remoteParty.DisplayName   = participant.DisplayName;
                    remoteParty.TimeInitiated = participant.TimeInitiated;
                    remoteParty.State         = participant.CallState;

                    phoneLine.RemoteParties.Add(remoteParty);

                    if ((phoneLine.RemoteParties.Count == 1) && (remoteParty.State == BriaAPI.CallStates.Ringing))
                    {
                        phoneLine.IsRinging = true;
                    }
                    else
                    {
                        phoneLine.IsRinging = false;
                    }
                }
            }

            // Finally clear out any phoneLine that is no longer active
            for (int i = 0; i < 6; i++)
            {
                if (lineInUse[i] == false)
                {
                    phoneLines[i] = null;
                }
            }

            UpdateCallStates();
        }
示例#2
0
 private void OnCallStatus(object sender, BriaAPI.CallStatusEventArgs args)
 {
     this.BeginInvoke(onCallStatusDelegate, new Object[] { args });
 }