UpdateCallState() private method

private UpdateCallState ( CALL_STATE new_state ) : void
new_state CALL_STATE
return void
示例#1
0
 private static void HandleCustomEvent(FSEvent evt, string uuid)
 {
     if (evt.subclass_name == "portaudio::ringing")
     {
         Utils.DebugEventDump(evt);
         if ((from c in calls where c._leg_a_uuid == uuid && c.call_ended == false select c).Count() > 0)                //only care about first ring
         {
             return;
         }
         Call call = new Call();
         call.SetCallInfoFromEvent(evt);
         String gw_id = (from c in channels where c.Key == call.leg_b_uuid select c.Value.gateway_id).SingleOrDefault();
         call.account = (from a in Account.accounts where a.gateway_id == gw_id select a).SingleOrDefault();
         calls.Add(call);
         call.UpdateCallState(CALL_STATE.Ringing, active_call ?? call);
     }
     else if (evt.subclass_name == "portaudio::makecall")
     {
         Utils.DebugEventDump(evt);
         if (evt.get_header("fail") == "true")
         {
             MessageBox.Show("Make Call failed!!!, came from portaudio not sure why");
             return;
         }
         Call call = new Call();
         call.is_outgoing = true;
         call.SetCallInfoFromEvent(evt);
         if (call.other_party_number == "fsc_conference")
         {
             call.visibility = Visibility.Collapsed;
             Conference.instance.our_conference_call = call;
             call.is_conference_call = true;
         }
         calls.Add(call);
         call.UpdateCallState(call.is_conference_call ? CALL_STATE.Answered : CALL_STATE.Ringing, call);
     }
     else if (evt.subclass_name == "portaudio::callheld" || evt.subclass_name == "portaudio::callresumed")
     {
         String paid_str = evt.get_header("variable_pa_call_id");
         if (String.IsNullOrEmpty(paid_str))
         {
             return;
         }
         int  portaudio_id = Int32.Parse(paid_str);
         Call call         = (from c in calls where c.portaudio_id == portaudio_id && c.call_ended == false select c).SingleOrDefault();
         if (call == null)
         {
             return;
         }
         if (evt.subclass_name == "portaudio::callresumed")
         {
             call.UpdateCallState(CALL_STATE.Answered, call);
         }
         else
         {
             call.UpdateCallState(call.state == CALL_STATE.Ringing ? CALL_STATE.Hold_Ringing : CALL_STATE.Hold, call == active_call ? null : active_call);
         }
     }
 }
示例#2
0
        public static void HandleHangupCompleteEvent(FSEvent evt, String uuid)
        {
            Utils.DebugEventDump(evt);
            Call call = (from c in calls where c.call_ended == false && (c.leg_a_uuid == uuid || c.leg_b_uuid == uuid) select c).SingleOrDefault();

            if (call == null || call.call_ended)
            {
                return;
            }

            CALL_STATE new_state = CALL_STATE.None;


            if (call.state != CALL_STATE.Answered && call.state != CALL_STATE.Missed && call.state != CALL_STATE.Hold)
            {
                if (String.IsNullOrEmpty(call.note))
                {
                    call.note = evt.get_header("variable_sip_hangup_phrase");
                }
                if (!call.is_outgoing && call.state == CALL_STATE.Ringing)
                {
                    new_state = CALL_STATE.Missed;
                }
                else
                {
                    new_state = CALL_STATE.Failed;
                }
            }
            else if (call.state == CALL_STATE.Answered || call.state == CALL_STATE.Hold)
            {
                new_state = CALL_STATE.Ended;
            }

            if (new_state == CALL_STATE.None)
            {
                throw new Exception("Not sure what happened call was at state...: " + call.state);
            }
            Call new_active_call;

            if (Call.active_call != call)
            {
                new_active_call = Call.active_call;
            }
            else
            {
                new_active_call = (from c in calls where c.state == CALL_STATE.Ringing && c.is_outgoing == false && c != call select c).FirstOrDefault();
            }
            call.UpdateCallState(new_state, new_active_call);
        }
示例#3
0
        private static void HandleChannelAnswerEvent(FSEvent evt, String uuid)
        {
            Call call = (from c in calls where c.leg_b_uuid == uuid && c.call_ended == false select c).SingleOrDefault();

            if (call == null)
            {
                String orig_dest = evt.get_header("Other-Leg-Destination-Number");
                if (orig_dest != "auto_answer")
                {
                    return;
                }
                call = new Call();
                call.SetCallInfoFromEvent(evt);
                String gw_id = (from c in channels where c.Key == call.leg_b_uuid select c.Value.gateway_id).SingleOrDefault();
                call.account = (from a in Account.accounts where a.gateway_id == gw_id select a).SingleOrDefault();
                calls.Add(call);
                call.UpdateCallState(CALL_STATE.Ringing, call);
            }
            if (call.state == CALL_STATE.Answered)
            {
                return;
            }

            if (call.state == CALL_STATE.Ringing || (call.state == CALL_STATE.Hold_Ringing && !call.is_outgoing))
            {
                call.UpdateCallState(CALL_STATE.Answered, (call.is_outgoing || call.is_conference_call) ? active_call : call);
            }
            else if (call.state == CALL_STATE.Hold_Ringing)
            {
                call.UpdateCallState(CALL_STATE.Hold, active_call);
            }
            else
            {
                throw new Exception("Unknown state, call answered but was not in a state of hold_ring or ringing");
            }
        }
示例#4
0
 private static void HandleCustomEvent(FSEvent evt, string uuid)
 {
     if (evt.subclass_name == "portaudio::ringing") {
         Utils.DebugEventDump(evt);
         if ((from c in calls where c._leg_a_uuid == uuid && c.call_ended == false select c).Count() > 0)//only care about first ring
             return;
         Call call = new Call();
         call.SetCallInfoFromEvent(evt);
         String gw_id = (from c in channels where c.Key == call.leg_b_uuid select c.Value.gateway_id).SingleOrDefault();
         call.account = (from a in Account.accounts where a.gateway_id == gw_id select a).SingleOrDefault();
         calls.Add(call);
         call.UpdateCallState(CALL_STATE.Ringing, active_call ?? call);
     }
     else if (evt.subclass_name == "portaudio::makecall") {
         Utils.DebugEventDump(evt);
         if (evt.get_header("fail") == "true") {
             MessageBox.Show("Make Call failed!!!, came from portaudio not sure why");
             return;
         }
         Call call = new Call();
         call.is_outgoing = true;
         call.SetCallInfoFromEvent(evt);
         if (call.other_party_number == "fsc_conference"){
             call.visibility = Visibility.Collapsed;
             Conference.instance.our_conference_call = call;
             call.is_conference_call = true;
         }
         calls.Add(call);
         call.UpdateCallState(call.is_conference_call ? CALL_STATE.Answered : CALL_STATE.Ringing, call);
     }
     else if (evt.subclass_name == "portaudio::callheld" || evt.subclass_name == "portaudio::callresumed") {
         String paid_str = evt.get_header("variable_pa_call_id");
         if (String.IsNullOrEmpty(paid_str))
             return;
         int portaudio_id = Int32.Parse(paid_str);
         Call call = (from c in calls where c.portaudio_id == portaudio_id && c.call_ended == false select c).SingleOrDefault();
         if (call == null)
             return;
         if (evt.subclass_name == "portaudio::callresumed")
             call.UpdateCallState(CALL_STATE.Answered, call);
         else
             call.UpdateCallState(call.state == CALL_STATE.Ringing ? CALL_STATE.Hold_Ringing : CALL_STATE.Hold, call == active_call ? null : active_call);
     }
 }
示例#5
0
        private static void HandleChannelAnswerEvent(FSEvent evt, String uuid)
        {
            Call call = (from c in calls where c.leg_b_uuid == uuid && c.call_ended == false select c).SingleOrDefault();
            if (call == null){
                String orig_dest = evt.get_header("Other-Leg-Destination-Number");
                if (orig_dest != "auto_answer")
                    return;
                call = new Call();
                call.SetCallInfoFromEvent(evt);
                String gw_id = (from c in channels where c.Key == call.leg_b_uuid select c.Value.gateway_id).SingleOrDefault();
                call.account = (from a in Account.accounts where a.gateway_id == gw_id select a).SingleOrDefault();
                calls.Add(call);
                call.UpdateCallState(CALL_STATE.Ringing, call);
            }
            if (call.state == CALL_STATE.Answered)
                return;

            if (call.state == CALL_STATE.Ringing || (call.state == CALL_STATE.Hold_Ringing && !call.is_outgoing))
                call.UpdateCallState(CALL_STATE.Answered, (call.is_outgoing || call.is_conference_call) ? active_call : call);
            else if (call.state == CALL_STATE.Hold_Ringing)
                call.UpdateCallState(CALL_STATE.Hold, active_call);
            else
                throw new Exception("Unknown state, call answered but was not in a state of hold_ring or ringing");
        }