danbarua / NEventSocket

A reactive FreeSwitch eventsocket library for Modern .Net
Mozilla Public License 2.0
74 stars 37 forks source link

Schedule Hangup #40

Open phoober-net opened 8 years ago

phoober-net commented 8 years ago

Hi Dan, I added this to your code for scheduled hangup and I thought maybe you'd like to add something similar to your version as I find it handy:

--in apiextension.cs

        public static Task<ApiResponse> ScheduleHangup(
this EventSocket eventSocket, 
string uuid, 
string value, 
HangupCause hangupCause = HangupCause.NormalClearing)
        {
            return eventSocket.SendApi("sched_hangup +{0} {1} {2}".Fmt(
value, uuid, hangupCause.ToString().ToUpperWithUnderscores()));
        }

--in basicchannel.cs

        public Task ScheduleHangup(HangupCause hangupCause = FreeSwitch.HangupCause.NormalClearing)
        {
            return
                RunIfAnswered(
                    () =>
                    eventSocket.SendApi("sched_hangup +10 {0} {1}".Fmt(UUID, hangupCause.ToString().ToUpperWithUnderscores())),
                    true);
        }
danbarua commented 8 years ago

Todo: include this in v2