danbarua / NEventSocket

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

BridgeTo does not return BridgeResult #63

Open mguerrieri opened 7 years ago

mguerrieri commented 7 years ago

Is there a reason that the BridgeTo method swallows the result of the bridge instead of returning it? This makes getting the results of the bridge attempt challenging.

danbarua commented 7 years ago

This is what I use:

if (!channel.IsBridged)
{
  ColorConsole.WriteLine("Bridge Failed - {0}"
       .Fmt(channel.GetVariable("last_bridge_hangup_cause")).Red());
  await channel.Play("ivr/ivr-call_rejected.wav");
  await channel.Hangup(HangupCause.NormalTemporaryFailure);
}

The idea that by keeping all the state accessible via the channel object your code will be more succinct.

danbarua commented 7 years ago

I'm considering there may be a case for strongly typed access to the most commonly-used channel vars eg channel.Variables.BridgeHangupCause

danbarua commented 7 years ago

ColorConsole.WriteLine("Bridge Failed - {0}".Fmt(channel.Variables.BridgeHangupCause).Red());

^ that's a bit better.

I've been going around around on this trying to make this API usable as you can see here: https://github.com/danbarua/NEventSocket/issues/18