danbarua / NEventSocket

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

Send DTMF to channel #4

Closed Anber closed 9 years ago

Anber commented 9 years ago

Hello again!

Why part of channel's methods stored in Channel and another part in BasicChannel?

danbarua commented 9 years ago

Hi, when you bridge a channel to another channel, then you can access the b-leg channel via aLeg.Bridge.Channel, which returns a BasicChannel instance. The idea is that there are some things you can do with the b-channel and some things you can't - we'll need to play with FreeSwitch and the ESL a bit more to figure out what these are. If you think you can do it with the b-leg channel then put the functionality in BasicChannel, if it can only be done with the a-leg then put it on the Channel object.

Feel free to chime in with feedback and ideas on this, the aim of the Channels API is to make working with the ESL as easy as possible.

I'm thinking of re-writing the bridge functionality to be more functional and reactive, so instead of aLeg.Bridge.Channel you might have an observable sequence of channels like this:

public IObservable<BasicChannel> BridgedChannels {get;}

which you would then observe like this:

aLeg.BridgedChannels.Subscribe(async bLeg => { //do things with b-leg here}
await aLeg.BridgeTo("sofia/gateway/gw/1234");

if (aLeg["originate_disposition"] != "SUCCESS") //i haven't tested this!
{
  //bridge failed
  //otherwise aLeg.BridgedChannels observable will invoke the subscribed callback
}

This make attened transfers work better, eg. if the b-leg hangs up before the c-leg answers, and the c-leg rejects the call, FreeSwitch will then attempt to originate back to the b-leg endpoint with a new Channel. By this point the attended transfer application has completed already.

danbarua commented 9 years ago

So, you may want to try putting this on the BasicChannel class instead and see if that works. We could probably end up writing a book on all the quirks of FreeSwitch that you figure out when you start writing an ESL library for it.

Anber commented 9 years ago

You are right. BasicChannel is more suitable for it, because usually we need send DTMF to b-leg.