示例#1
0
 public static void ForEach(this switch_event e, Action <String, String> action)
 {
     for (var x = e.headers; x != null; x = x.next)
     {
         action(x.name, x.value);
     }
 }
示例#2
0
        public static switch_event SwitchEventDupe(switch_event evt)
        {
            IntPtr clone_ptr_ptr = Marshal.AllocCoTaskMem(IntPtr.Size);

            freeswitch.switch_event_dup(new SWIGTYPE_p_p_switch_event(clone_ptr_ptr, false), evt);
            SwitchEventWrap dupe_evt = new SwitchEventWrap(clone_ptr_ptr);

            return(dupe_evt);
        }
示例#3
0
        public static Boolean GetBooleanHeader(this switch_event e, String headerName)
        {
            var hv = e.GetValueOfHeader(headerName);

            hv = (String.IsNullOrEmpty(hv) ? "false" : hv);
            Boolean rv = false;

            Boolean.TryParse(hv, out rv);
            return(rv);
        }
示例#4
0
        public static switch_event SwitchEventDupe(switch_event evt)
        {
            IntPtr clone_ptr_ptr = Marshal.AllocCoTaskMem(IntPtr.Size);

            freeswitch.switch_event_dup(new SWIGTYPE_p_p_switch_event(clone_ptr_ptr, false), evt);
            IntPtr       event_ptr = (IntPtr)Marshal.PtrToStructure(clone_ptr_ptr, typeof(IntPtr));
            switch_event dupe_evt  = new switch_event(event_ptr, false);

            Marshal.FreeCoTaskMem(clone_ptr_ptr);
            return(dupe_evt);
        }
示例#5
0
 public static switch_event_header GetHeader(this switch_event e, String HeaderName)
 {
     for (var x = e.headers; x != null; x = x.next)
     {
         if (HeaderName.ToLower() == x.name.ToLower())
         {
             return(x);
         }
     }
     return(null);
 }
示例#6
0
        public static Dictionary <String, String> ExtractVars(this switch_event e)
        {
            var r = new Dictionary <String, String>();

            for (var x = e.headers; x != null; x = x.next)
            {
                if (x.name.StartsWith("variable_"))
                {
                    r.Add(x.name.ToLower().Replace("variable_", String.Empty),
                          x.value);
                }
            }
            return(r);
        }
        private void actual_event_handler(switch_event evt)
        {
            if (evt.event_id == switch_event_types_t.SWITCH_EVENT_MODULE_LOAD)
            {
                return;
            }

            if (evt.event_id == switch_event_types_t.SWITCH_EVENT_CUSTOM && evt.subclass_name == "sofia::gateway_state")
            {
                blockConsole.Text = "Sofia Gateway State: " + freeswitch.switch_event_get_header(evt, "State") + "\r\n" + blockConsole.Text;
            }
            else
            {
                blockConsole.Text = "Event " + evt.event_id + "\r\n" + blockConsole.Text;
            }
        }
示例#8
0
        private ArgCollection headers;              // Dictionary of event headers

        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="switchArgs">The low-level event arguments.</param>
        internal SwitchEvent(switch_event switchArgs)
        {
            this.switchArgs = switchArgs;
            this.EventType  = (SwitchEventCode)switchArgs.event_id;
            this.Priority   = (SwitchPriority)switchArgs.priority;

            // Load the headers into a read-only ArgCollection.

            headers = new ArgCollection(ArgCollectionType.Unconstrained);

            for (var header = switchArgs.headers; header != null; header = header.next)
            {
                headers[header.name] = Helper.UrlDecode(header.value);
            }

            headers.IsReadOnly = true;

            // Parse the common headers.

            try
            {
                this.SwitchID = new Guid(headers["Core-UUID"]);
            }
            catch (Exception e)
            {
                SysLog.LogException(e);
            }

            try
            {
                this.EventDateUtc = Helper.ParseInternetDate(headers["Event-Date-GMT"]);
            }
            catch (Exception e)
            {
                SysLog.LogException(e);
            }
        }
示例#9
0
 public static void Dump(this switch_event e)
 {
     e.ForEach((n, v) => Console.WriteLine("{0}={1}", n, v));
 }
示例#10
0
 public static Guid GetGuid(this switch_event e)
 {
     return(e.GetHeader("Unique-ID") == null ? Guid.Empty : Guid.Parse(e.GetHeader("Unique-ID").value));
 }
示例#11
0
        public static String GetValueOfHeader(this switch_event e, String headerName, String defaultValue = "")
        {
            var head = e.GetHeader(headerName);

            return(head == null ? defaultValue : head.value);
        }
示例#12
0
 public FSEvent(switch_event evt)
 {
     this.evt = evt;
 }