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); } }
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); }
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); }
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); }
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); }
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; } }
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); } }
public static void Dump(this switch_event e) { e.ForEach((n, v) => Console.WriteLine("{0}={1}", n, v)); }
public static Guid GetGuid(this switch_event e) { return(e.GetHeader("Unique-ID") == null ? Guid.Empty : Guid.Parse(e.GetHeader("Unique-ID").value)); }
public static String GetValueOfHeader(this switch_event e, String headerName, String defaultValue = "") { var head = e.GetHeader(headerName); return(head == null ? defaultValue : head.value); }
public FSEvent(switch_event evt) { this.evt = evt; }