How to invoke Freeswitch APIs from other modules
Hi folks, I am working on a pet project in order to become more familiar with Freeswitch. I have added my own module and APIs successfully, but am stuck when it comes to communicating with the other modules in Freeswitch. I see that other modules "export" functionality via APIs, but am not sure how, from within a C software routine in another Freeswitch module, that I should invoke this functionality. More specifically I want to call the sofia module API to flush all internal registrations (flush_inbound_reg) when some condition is triggered in my module. This module is written in C code, and I have googled my brains out trying to find an example of how to do this. Which is better: mod_event_socket. mod? xml_curl? RPC? I cannot seem to find any examples of how to create events in C (e.g. what parameters need to be specified), and what is the best solution for local communications. I could modify my local copy of sofia to provide direct calls, but I prefer to understand how this is intended to be done with the existing tools. I have the feeling I am missing something simple and would appreciate any pointers that anyone can provide. Thanks, Peter
Do you just want to run a command from your C mod? switch_stream_handle_t stream = { 0 }; SWITCH_STANDARD_STREAM(stream); switch_api_execute("show", "channels", NULL, &stream); printf("result: %s\n", (char *) stream.data); switch_safe_free(stream.data); On Thu, Jan 16, 2014 at 5:22 PM, Peter Hillier <peterhillier@yahoo.com>wrote:
Hi folks, I am working on a pet project in order to become more familiar with Freeswitch. I have added my own module and APIs successfully, but am stuck when it comes to communicating with the other modules in Freeswitch. I see that other modules "export" functionality via APIs, but am not sure how, from within a C software routine in another Freeswitch module, that I should invoke this functionality.
More specifically I want to call the sofia module API to flush all internal registrations (flush_inbound_reg) when some condition is triggered in my module. This module is written in C code, and I have googled my brains out trying to find an example of how to do this. Which is better: mod_event_socket. mod? xml_curl? RPC? I cannot seem to find any examples of how to create events in C (e.g. what parameters need to be specified), and what is the best solution for local communications.
I could modify my local copy of sofia to provide direct calls, but I prefer to understand how this is intended to be done with the existing tools. I have the feeling I am missing something simple and would appreciate any pointers that anyone can provide.
Thanks, Peter
_________________________________________________________________________ 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-dev mailing list FreeSWITCH-dev@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev http://www.freeswitch.org
-- Anthony Minessale II ♬ @anthmfs ♬ @FreeSWITCH ♬ ☞ http://freeswitch.org/ ☞ http://cluecon.com/ ☞ http://twitter.com/FreeSWITCH ☞ irc.freenode.net #freeswitch ☞ *http://freeswitch.org/g+ <http://freeswitch.org/g+>* ClueCon Weekly Development Call ☎ sip:888@conference.freeswitch.org ☎ +19193869900
Thanks very much. That was in fact exactly what I was looking for. After posting I continued to dig around and actually found a link that illustrated exactly what you proposed: http://wiki.sangoma.com/FreeSWITCH-ESL Best regards, Peter
participants (2)
-
Anthony Minessale
-
Peter Hillier