Is there a way to call sofia_contact from chatplan lua script
Hello, I'm trying to detect if a user is online within a lua script called from a chatplan.
From what I've read I should use sofia_contact in the chatplan, save the output in a custom channel variable and read the variable in my lua script. However as there is no session object active i don't see an easy way to read my custom channel variable from within my lua script.
How would you more experienced folks out there do this? I just want to know if the user is offline, so that I can send the message via other means if they are etc. Thanks in advance James
I have a lua script that does this: function extension_registered(domain_name, sip_profile, extension) api = freeswitch.API(); result = api:execute("sofia_contact", sip_profile.."/"..extension.."@"..domain_name); if (result == "error/user_not_registered") then return false; else return true; end end IIRC, you can hardcode the sip_profile to * and just drop the @domain_name part. -Avi On Tue, Jul 30, 2013 at 6:22 PM, James Lotery <jlotery@gmail.com> wrote:
Hello, I'm trying to detect if a user is online within a lua script called from a chatplan.
From what I've read I should use sofia_contact in the chatplan, save the output in a custom channel variable and read the variable in my lua script. However as there is no session object active i don't see an easy way to read my custom channel variable from within my lua script.
How would you more experienced folks out there do this? I just want to know if the user is offline, so that I can send the message via other means if they are etc.
Thanks in advance
James
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
Works great - I didn't realise I could call sofia_contact via the api interface. Thanks a lot for your help. James On Tue, Jul 30, 2013 at 11:53 PM, Avi Marcus <avi@avimarcus.net> wrote:
I have a lua script that does this:
function extension_registered(domain_name, sip_profile, extension) api = freeswitch.API(); result = api:execute("sofia_contact", sip_profile.."/"..extension.."@"..domain_name); if (result == "error/user_not_registered") then return false; else return true; end end
IIRC, you can hardcode the sip_profile to * and just drop the @domain_name part.
-Avi
On Tue, Jul 30, 2013 at 6:22 PM, James Lotery <jlotery@gmail.com> wrote:
Hello, I'm trying to detect if a user is online within a lua script called from a chatplan.
From what I've read I should use sofia_contact in the chatplan, save the output in a custom channel variable and read the variable in my lua script. However as there is no session object active i don't see an easy way to read my custom channel variable from within my lua script.
How would you more experienced folks out there do this? I just want to know if the user is offline, so that I can send the message via other means if they are etc.
Thanks in advance
James
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
Yeah, i was facing the same issue and had it resolved with the api lua object. Maybe a clarification is due on the wiki specifying that everything can be accessed via the chatplan via the api interface. On Wed, Jul 31, 2013 at 8:34 AM, James Lotery <jlotery@gmail.com> wrote:
Works great - I didn't realise I could call sofia_contact via the api interface.
Thanks a lot for your help.
James
On Tue, Jul 30, 2013 at 11:53 PM, Avi Marcus <avi@avimarcus.net> wrote:
I have a lua script that does this:
function extension_registered(domain_name, sip_profile, extension) api = freeswitch.API(); result = api:execute("sofia_contact", sip_profile.."/"..extension.."@"..domain_name); if (result == "error/user_not_registered") then return false; else return true; end end
IIRC, you can hardcode the sip_profile to * and just drop the @domain_name part.
-Avi
On Tue, Jul 30, 2013 at 6:22 PM, James Lotery <jlotery@gmail.com> wrote:
Hello, I'm trying to detect if a user is online within a lua script called from a chatplan.
From what I've read I should use sofia_contact in the chatplan, save the output in a custom channel variable and read the variable in my lua script. However as there is no session object active i don't see an easy way to read my custom channel variable from within my lua script.
How would you more experienced folks out there do this? I just want to know if the user is offline, so that I can send the message via other means if they are etc.
Thanks in advance
James
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
participants (3)
-
Avi Marcus
-
Daniel Ivanov
-
James Lotery