Discussion:
[Freeswitch-users] Running a session asynchronously from a Lua script
Adam Wilt
2010-02-05 02:48:07 UTC
Permalink
Hi all,

I want to park an inbound call and play hold music while I simultaneously
place another outbound call.
But the hold music doesn't play while the lua script is placing the second
call. When the lua script ends, the hold music finally starts.
Here's my example code:

#!/usr/local/bin/lua

session:answer()
api = freeswitch.API()
api:executeString("bgapi uuid_park " .. tostring(session.uuid))
api:executeString("bgapi uuid_broadcast " .. tostring(session.uuid) .. "
/freeswitch/sounds/music/8000/danza-espanola-op-37-h-142-xii-arabesca.wav")
local new_session =
freeswitch.Session("sofia/gateway/myprovider/15555555555")


So it seems like the script is blocking the original session, despite the
fact that I'm using bgapi. I'd really appreciate if somebody could help me
with this.

By the way, I'm using FreeSWITCH 1.0.4 in Windows.

Thanks,
Adam
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20100204/f4f4ea15/attachment-0001.html
Brian West
2010-02-05 03:23:46 UTC
Permalink
I wouldn't do it like that...

I would let FreeSWITCH do what its good at and stop trying to create and manage sessions manually.

-- You can optionally answer but you need to set transfer_ringback instead of ringback.
session:setVariable("ringback", "local_stream://moh");
session:setVariable("ignore_early_media", "true");
session:execute("bridge","user/1007");

Which can also be expressed in pure XML as such:

<extension name="1234">
<condition field="destination_number" expression="^1234$">
<action application="set" data="ringback=local_stream://moh"/>
<action application="set" data="ignore_early_media=true"/>
<action application="bridge" data="user/1007"/>
</condition>
</extension>

There is really no need to do this with Lua. The XML dialplan can do some VERY complex things once you wrap your head around it.

In addition I would recommend you get the latest 1.0.5 build http://files-sync.freeswitch.org/windows_installer/ Its tagged as 1.0.4 and shouldn't be.

/b
Post by Adam Wilt
Hi all,
I want to park an inbound call and play hold music while I simultaneously place another outbound call.
But the hold music doesn't play while the lua script is placing the second call. When the lua script ends, the hold music finally starts.
#!/usr/local/bin/lua
session:answer()
api = freeswitch.API()
api:executeString("bgapi uuid_park " .. tostring(session.uuid))
api:executeString("bgapi uuid_broadcast " .. tostring(session.uuid) .. " /freeswitch/sounds/music/8000/danza-espanola-op-37-h-142-xii-arabesca.wav")
local new_session = freeswitch.Session("sofia/gateway/myprovider/15555555555")
So it seems like the script is blocking the original session, despite the fact that I'm using bgapi. I'd really appreciate if somebody could help me with this.
By the way, I'm using FreeSWITCH 1.0.4 in Windows.
Thanks,
Adam
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20100204/c4c1fc03/attachment.html
Adam Wilt
2010-02-05 03:49:36 UTC
Permalink
Brian,

Thanks for the reply.
The problem is I don't want the two parties to speak to each other. I want
one party to wait on hold while the system interacts with the other party.
Then the system will hang-up on the second party and start interacting with
the first party again.

Thanks,
Adam
Post by Brian West
I wouldn't do it like that...
I would let FreeSWITCH do what its good at and stop trying to create and
manage sessions manually.
-- You can optionally answer but you need to set transfer_ringback instead of ringback.
session:setVariable("ringback", "local_stream://moh");
session:setVariable("ignore_early_media", "true");
session:execute("bridge","user/1007");
<extension name="1234">
<condition field="destination_number" expression="^1234$">
<action application="set" data="ringback=local_stream://moh"/>
<action application="set" data="ignore_early_media=true"/>
<action application="bridge" data="user/1007"/>
</condition>
</extension>
There is really no need to do this with Lua. The XML dialplan can do some
VERY complex things once you wrap your head around it.
In addition I would recommend you get the latest 1.0.5 build
http://files-sync.freeswitch.org/windows_installer/ Its tagged as 1.0.4
and shouldn't be.
/b
Hi all,
I want to park an inbound call and play hold music while I simultaneously
place another outbound call.
But the hold music doesn't play while the lua script is placing the second
call. When the lua script ends, the hold music finally starts.
#!/usr/local/bin/lua
session:answer()
api = freeswitch.API()
api:executeString("bgapi uuid_park " .. tostring(session.uuid))
api:executeString("bgapi uuid_broadcast " .. tostring(session.uuid) .. "
/freeswitch/sounds/music/8000/danza-espanola-op-37-h-142-xii-arabesca.wav")
local new_session =
freeswitch.Session("sofia/gateway/myprovider/15555555555")
So it seems like the script is blocking the original session, despite the
fact that I'm using bgapi. I'd really appreciate if somebody could help me
with this.
By the way, I'm using FreeSWITCH 1.0.4 in Windows.
Thanks,
Adam
_______________________________________________
FreeSWITCH-users mailing list
FreeSWITCH-users at lists.freeswitch.org
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20100204/22e157d3/attachment.html
Brian West
2010-02-05 03:57:24 UTC
Permalink
ok the use the api to "originate" the call to say an extension that plays music. But if they never talk to each other what is the point of the two calls in the same script?

/b
Post by Adam Wilt
Brian,
Thanks for the reply.
The problem is I don't want the two parties to speak to each other. I want one party to wait on hold while the system interacts with the other party. Then the system will hang-up on the second party and start interacting with the first party again.
Thanks,
Adam
Brian West
2010-02-05 03:57:24 UTC
Permalink
ok the use the api to "originate" the call to say an extension that plays music. But if they never talk to each other what is the point of the two calls in the same script?

/b
Post by Adam Wilt
Brian,
Thanks for the reply.
The problem is I don't want the two parties to speak to each other. I want one party to wait on hold while the system interacts with the other party. Then the system will hang-up on the second party and start interacting with the first party again.
Thanks,
Adam
Adam Wilt
2010-02-05 03:49:36 UTC
Permalink
Brian,

Thanks for the reply.
The problem is I don't want the two parties to speak to each other. I want
one party to wait on hold while the system interacts with the other party.
Then the system will hang-up on the second party and start interacting with
the first party again.

Thanks,
Adam
Post by Brian West
I wouldn't do it like that...
I would let FreeSWITCH do what its good at and stop trying to create and
manage sessions manually.
-- You can optionally answer but you need to set transfer_ringback instead of ringback.
session:setVariable("ringback", "local_stream://moh");
session:setVariable("ignore_early_media", "true");
session:execute("bridge","user/1007");
<extension name="1234">
<condition field="destination_number" expression="^1234$">
<action application="set" data="ringback=local_stream://moh"/>
<action application="set" data="ignore_early_media=true"/>
<action application="bridge" data="user/1007"/>
</condition>
</extension>
There is really no need to do this with Lua. The XML dialplan can do some
VERY complex things once you wrap your head around it.
In addition I would recommend you get the latest 1.0.5 build
http://files-sync.freeswitch.org/windows_installer/ Its tagged as 1.0.4
and shouldn't be.
/b
Hi all,
I want to park an inbound call and play hold music while I simultaneously
place another outbound call.
But the hold music doesn't play while the lua script is placing the second
call. When the lua script ends, the hold music finally starts.
#!/usr/local/bin/lua
session:answer()
api = freeswitch.API()
api:executeString("bgapi uuid_park " .. tostring(session.uuid))
api:executeString("bgapi uuid_broadcast " .. tostring(session.uuid) .. "
/freeswitch/sounds/music/8000/danza-espanola-op-37-h-142-xii-arabesca.wav")
local new_session =
freeswitch.Session("sofia/gateway/myprovider/15555555555")
So it seems like the script is blocking the original session, despite the
fact that I'm using bgapi. I'd really appreciate if somebody could help me
with this.
By the way, I'm using FreeSWITCH 1.0.4 in Windows.
Thanks,
Adam
_______________________________________________
FreeSWITCH-users mailing list
FreeSWITCH-users at lists.freeswitch.org
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20100204/22e157d3/attachment-0002.html
Adam Wilt
2010-02-05 02:48:07 UTC
Permalink
Hi all,

I want to park an inbound call and play hold music while I simultaneously
place another outbound call.
But the hold music doesn't play while the lua script is placing the second
call. When the lua script ends, the hold music finally starts.
Here's my example code:

#!/usr/local/bin/lua

session:answer()
api = freeswitch.API()
api:executeString("bgapi uuid_park " .. tostring(session.uuid))
api:executeString("bgapi uuid_broadcast " .. tostring(session.uuid) .. "
/freeswitch/sounds/music/8000/danza-espanola-op-37-h-142-xii-arabesca.wav")
local new_session =
freeswitch.Session("sofia/gateway/myprovider/15555555555")


So it seems like the script is blocking the original session, despite the
fact that I'm using bgapi. I'd really appreciate if somebody could help me
with this.

By the way, I'm using FreeSWITCH 1.0.4 in Windows.

Thanks,
Adam
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20100204/f4f4ea15/attachment-0002.html
Brian West
2010-02-05 03:23:46 UTC
Permalink
I wouldn't do it like that...

I would let FreeSWITCH do what its good at and stop trying to create and manage sessions manually.

-- You can optionally answer but you need to set transfer_ringback instead of ringback.
session:setVariable("ringback", "local_stream://moh");
session:setVariable("ignore_early_media", "true");
session:execute("bridge","user/1007");

Which can also be expressed in pure XML as such:

<extension name="1234">
<condition field="destination_number" expression="^1234$">
<action application="set" data="ringback=local_stream://moh"/>
<action application="set" data="ignore_early_media=true"/>
<action application="bridge" data="user/1007"/>
</condition>
</extension>

There is really no need to do this with Lua. The XML dialplan can do some VERY complex things once you wrap your head around it.

In addition I would recommend you get the latest 1.0.5 build http://files-sync.freeswitch.org/windows_installer/ Its tagged as 1.0.4 and shouldn't be.

/b
Post by Adam Wilt
Hi all,
I want to park an inbound call and play hold music while I simultaneously place another outbound call.
But the hold music doesn't play while the lua script is placing the second call. When the lua script ends, the hold music finally starts.
#!/usr/local/bin/lua
session:answer()
api = freeswitch.API()
api:executeString("bgapi uuid_park " .. tostring(session.uuid))
api:executeString("bgapi uuid_broadcast " .. tostring(session.uuid) .. " /freeswitch/sounds/music/8000/danza-espanola-op-37-h-142-xii-arabesca.wav")
local new_session = freeswitch.Session("sofia/gateway/myprovider/15555555555")
So it seems like the script is blocking the original session, despite the fact that I'm using bgapi. I'd really appreciate if somebody could help me with this.
By the way, I'm using FreeSWITCH 1.0.4 in Windows.
Thanks,
Adam
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20100204/c4c1fc03/attachment-0002.html
Loading...