FSClient.Call.SetCallInfoFromEvent C# (CSharp) Méthode

SetCallInfoFromEvent() private méthode

private SetCallInfoFromEvent ( FSEvent evt ) : void
evt FSEvent
Résultat void
        private void SetCallInfoFromEvent(FSEvent evt)
        {
            leg_a_uuid = evt.get_header("Unique-ID");
            leg_b_uuid = evt.get_header("Other-Leg-Unique-ID");
            if (is_outgoing) {
                bool is_sip_direct = false;
                if (DestNumberRegex == null)
                    DestNumberRegex  = new Regex("sofia/gateway/([0-9]+)/(.+)", RegexOptions.Compiled);
                Match match = DestNumberRegex.Match(evt.get_header("Caller-Destination-Number"));
                if (! match.Success){
                    if (DestSipRegex == null)
                        DestSipRegex = new Regex("gw_ref=([0-9]+)}sofia/softphone/(.+)", RegexOptions.Compiled);
                    match = DestSipRegex.Match(evt.get_header("Caller-Destination-Number"));
                    is_sip_direct = true;
                }

                if (match.Success && match.Groups.Count == 3) {
                    String gw_id = match.Groups[1].Value;
                    account = (from a in Account.accounts where a.gateway_id == gw_id select a).SingleOrDefault();
                    other_party_number = is_sip_direct ? "sip:" + match.Groups[2].Value : match.Groups[2].Value;
                }
            }
            else {
                other_party_name = evt.get_header("Caller-Caller-ID-Name");
                other_party_number = evt.get_header("Caller-Caller-ID-Number");
            }
            if (String.IsNullOrEmpty(other_party_name))
                other_party_name = other_party_number;

            String paid_str = evt.get_header("variable_pa_call_id");
            if (!String.IsNullOrEmpty(paid_str))
                portaudio_id = Int32.Parse(paid_str);
        }

Usage Example

Exemple #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);
         }
     }
 }
All Usage Examples Of FSClient.Call::SetCallInfoFromEvent