[Freeswitch-users] ESL originate retreiving dialresult.

Peter Olsson peter.olsson at visionutveckling.se
Thu Apr 12 18:49:56 MSD 2012


What you should do (and what my intention was to describe) is to change how you detect state changes to the call. Now you use a poll mechanism. If you changed this to listen to events instead, you would get the changes as soon as it happens, and you will be able to read all the variables from these events.

Also, "originate" will not return until media is present, so if you dial somewhere without early media, your existing code will hang until the call has been answered, to get around this you can use bpapi instead of Api, which will fire up a new thread in FS during the setup of the call and return immediately.

A short example;

1.       Send bgapi originate ..... to FS - this will return immediately.

2.       Start polling for events, as soon as the state of your new call changes an event will be sent, with the UUID that you specified.

3.       Read the variables in the event to get further information. Since the variables are contained in the event object, it won't matter if the call was disconnected already.

It will require basic changes in your code, but ESL was made to work this way (async with events, not semi-async with polling), and it will make things easier for you in the future.

/Peter

Från: freeswitch-users-bounces at lists.freeswitch.org [mailto:freeswitch-users-bounces at lists.freeswitch.org] För Michael Lutz
Skickat: den 12 april 2012 16:25
Till: 'FreeSWITCH Users Help'
Ämne: Re: [Freeswitch-users] ESL originate retreiving dialresult.

Peter, I know, I am doing this allready, that is how I check the disposition while dialing already, I am using uuid_getvar to reach it.
The problem is, that when it is not answered, ie Busy or congestion, the session is killed by the core and no longer exists.
So when it stops, I cannot do a uuid_getvar anymore as the session no longer exists.

string cDialString = "{origination_uuid=" + thisDial.CallId_LegB // This my generated uuid
+ ",origination_caller_id_number=" + thisDial.CLIP
+ ",origination_caller_id_name=" + thisDial.CLIP
+ "}sofia/external/" + thisExtension.Destination+'@'+ thisDial.Gateway
+ " &park()";

var eslEvent = thisFSConnection.Connection.Api("originate", cDialString);
dispo = thisFSConnection.Connection.Api("uuid_getvar", thisDial.CallId_LegB + " endpoint_disposition").GetBody();

Stopwatch dialTimeout = new Stopwatch();
dialTimeout.Start();
while (CallIdExists(thisFSConnection, thisCall.callId) && CallIdExists(thisFSConnection, thisDial.CallId_LegB) && dispo == "EARLY MEDIA" && dialTimeout.ElapsedMilliseconds < thisDial.DialAttemptDuration*1000 )
{
if (dispo != dispoLast)
{
dispoLast = dispo;
}
dispo = thisFSConnection.Connection.Api("uuid_getvar", thisDial.CallId_LegB + " endpoint_disposition").GetBody();
Thread.Sleep(100);
}
dialTimeout.Stop();
dispo = thisFSConnection.Connection.Api("uuid_getvar", thisDial.CallId_LegB + " endpoint_disposition").GetBody();

if (dispo == "ANSWER")

The last dispo is never filled correctly, because the session no longer exist, unless it was answered...

Thanks,
Mike.


From: freeswitch-users-bounces at lists.freeswitch.org<mailto:freeswitch-users-bounces at lists.freeswitch.org> [mailto:freeswitch-users-bounces at lists.freeswitch.org]<mailto:[mailto:freeswitch-users-bounces at lists.freeswitch.org]> On Behalf Of Peter Olsson
Sent: donderdag 12 april 2012 11:34
To: 'FreeSWITCH Users Help'
Subject: Re: [Freeswitch-users] ESL originate retreiving dialresult.

If you're already creating a uuid manually thats just fine (no, you can not use the same uuid for two channels). Now you just need to parse the events for that channel when you start the originate. As soon as the originate does any progress events will report this, using the uuid that you have defined.

/Peter

Från: freeswitch-users-bounces at lists.freeswitch.org<mailto:freeswitch-users-bounces at lists.freeswitch.org> [mailto:freeswitch-users-bounces at lists.freeswitch.org]<mailto:[mailto:freeswitch-users-bounces at lists.freeswitch.org]> För Michael Lutz
Skickat: den 12 april 2012 10:41
Till: 'FreeSWITCH Users Help'
Ämne: Re: [Freeswitch-users] ESL originate retreiving dialresult.

I am allready using the origination_uuid and pass it with the originate command. I only create one now by using the create_uuid function.

So you say, don't create a new one and just use one of a session that already exists and is in progress? (so actually the session that is 'connected' to the inbound ESL session?  The originate/or system would not have a problem with that? I would be setting up two calls wioth the same UUID ... and how would my other uuid functions respond to that? I can assume a uuid kill would suddenly kill two legs?

Thanks,
Mike.


From: freeswitch-users-bounces at lists.freeswitch.org<mailto:freeswitch-users-bounces at lists.freeswitch.org> [mailto:freeswitch-users-bounces at lists.freeswitch.org]<mailto:[mailto:freeswitch-users-bounces at lists.freeswitch.org]> On Behalf Of Peter Olsson
Sent: donderdag 12 april 2012 10:26
To: 'FreeSWITCH Users Help'
Subject: Re: [Freeswitch-users] ESL originate retreiving dialresult.

Use the variable "origination_uuid", and set to an uuid that you know. Then it's possible to detect the events showing up for this channel uuid.

/Peter


Från: freeswitch-users-bounces at lists.freeswitch.org<mailto:freeswitch-users-bounces at lists.freeswitch.org> [mailto:freeswitch-users-bounces at lists.freeswitch.org]<mailto:[mailto:freeswitch-users-bounces at lists.freeswitch.org]> För Michael Lutz
Skickat: den 12 april 2012 10:11
Till: 'FreeSWITCH Users Help'
Ämne: [Freeswitch-users] ESL originate retreiving dialresult.

Hi Guys,

I am in an urgent matter an need help with something, I am using an ESL inbound connection to setup a new call.
It works fine on successful answered calls.

I am using the uuid_getvar api function whilst dialing to get the endpoint_disposition of the dialing uuid to check when a call is answered.
So when it's answered it will return "ANSWER".

The problem with this is that if an attempt fails, the endpoint disposition cannot be read with the uuid_getvar function because the dialing session is already gone.

What is the best way to get the result in realtime?, I really need to know the reason it failed.


Thanks for your help,
Mike.


!DSPAM:4f86e5a732761122815096!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20120412/64d727c2/attachment-0001.html 


Join us at ClueCon 2011 Aug 9-11, 2011
More information about the FreeSWITCH-users mailing list