Example #1
0
        public static IDisposable Bind(string id, switch_event_types_t event_types, string subclass_name, Action <EventBindingArgs> f, bool dupe)
        {
            switch_event_callback_delegate boundFunc;

            if (dupe)
            {
                boundFunc = (eventObj) =>
                {
                    var args = new EventBindingArgs {
                        EventObj = SwitchEventDupe(new switch_event(eventObj, false))
                    };
                    f(args);
                };
            }
            else
            {
                boundFunc = (eventObj) =>
                {
                    var args = new EventBindingArgs {
                        EventObj = new switch_event(eventObj, false)
                    };
                    f(args);
                };
            }
            var fp     = Marshal.GetFunctionPointerForDelegate(boundFunc);
            var swigFp = new SWIGTYPE_p_f_p_switch_event__void(fp, false);
            var res    = freeswitch.switch_event_bind(id, event_types, subclass_name, swigFp, null);

            if (res != switch_status_t.SWITCH_STATUS_SUCCESS)
            {
                throw new InvalidOperationException("Call to switch_event_bind failed, result: " + res + ".");
            }
            return(new EventBinding(swigFp, boundFunc));
        }
Example #2
0
 private EventBinding(SWIGTYPE_p_f_p_switch_event__void function, switch_event_callback_delegate origDelegate)
 {
     this.function = function;
     this.del      = origDelegate;
 }