[Freeswitch-dev] Originating from an event.
Hi, I¹m writing my own module and have a situation where I need to connect two endpoints in response to an event. I have the custom event tied into my module and I know my endpoints that I need to connect but it¹s not clear to me how to set up this connection. It appears that I cannot (or at least don¹t want) to set up this connection on the thread the event came in on as that stalls other events from coming in. I think I need to create a new thread and session then use switch_ivr_originate and bridge the two. That however seems easier said than done, so I must be missing something. Switch_thread_create looks fairly straight forward but in the examples of it they all are used in situations where a session already exists. It¹s uses the pool from that session. In the event handler I don¹t have any session. I need to set the entire phone call/session up from scratch. I keep looking for a ³switch_create_session² like call to setup this but that doesn¹t exist. Clearly I¹m going about it wrong. Are there any examples or docs on how to do this programmatically? I¹ve search and can¹t find anything like this. I¹m fairly new to FS but hopefully this isn¹t a total newbie question and that it makes sense. I¹m excited for ClueCon, that¹ll shed a lot of light on FS for me. Kevin
here is the recipe: ingredients: 1) Your own private struct that contains a pool pointer and any other data you want to use in the thread. 2) a pool pointer // define your struct typedef struct { switch_memory_pool_t *pool; int num; } my_helper_t; // declare your variables switch_memory_pool_t *pool; my_helper_t *mh; // create pool switch_core_new_memory_pool(&pool); // use the pool to create the struct mh = (my_helper_t *) switch_core_alloc(pool, sizeof(*mh)); // populate the struct mh->pool = pool; mh->num = 42; // now pass mh as the private data of the thread and get it back in your thread. // just destroy the pool at the end of your function static void *SWITCH_THREAD_FUNC my_thread(switch_thread_t *thread, void *obj) { my_helper_t *mh = (my_helper_t *) obj; // Do your thang switch_core_destroy_memory_pool(&mh->pool); mh = NULL; } On Tue, Jun 16, 2009 at 9:28 AM, Kevin Snow <kevin.snow@ooma.com> wrote:
Hi,
I’m writing my own module and have a situation where I need to connect two endpoints in response to an event. I have the custom event tied into my module and I know my endpoints that I need to connect but it’s not clear to me how to set up this connection.
It appears that I cannot (or at least don’t want) to set up this connection on the thread the event came in on as that stalls other events from coming in. I think I need to create a new thread and session then use switch_ivr_originate and bridge the two. That however seems easier said than done, so I must be missing something.
Switch_thread_create looks fairly straight forward but in the examples of it they all are used in situations where a session already exists. It’s uses the pool from that session. In the event handler I don’t have any session. I need to set the entire phone call/session up from scratch. I keep looking for a “switch_create_session” like call to setup this but that doesn’t exist. Clearly I’m going about it wrong.
Are there any examples or docs on how to do this programmatically? I’ve search and can’t find anything like this.
I’m fairly new to FS but hopefully this isn’t a total newbie question and that it makes sense. I’m excited for ClueCon, that’ll shed a lot of light on FS for me.
Kevin
_______________________________________________ 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 FreeSWITCH http://www.freeswitch.org/ ClueCon http://www.cluecon.com/ AIM: anthm MSN:anthony_minessale@hotmail.com <MSN%3Aanthony_minessale@hotmail.com> GTALK/JABBER/PAYPAL:anthony.minessale@gmail.com<PAYPAL%3Aanthony.minessale@gmail.com> IRC: irc.freenode.net #freeswitch FreeSWITCH Developer Conference sip:888@conference.freeswitch.org <sip%3A888@conference.freeswitch.org> iax:guest@conference.freeswitch.org/888 googletalk:conf+888@conference.freeswitch.org<googletalk%3Aconf%2B888@conference.freeswitch.org> pstn:213-799-1400
Kevin, If you get this working then let us know. This is perfect information to put into the wiki: http://wiki.freeswitch.org/wiki/Authoring_Freeswitch_Modules We can figure out the best place to put it. -MC On Tue, Jun 16, 2009 at 9:06 AM, Anthony Minessale < anthony.minessale@gmail.com> wrote:
here is the recipe:
ingredients:
1) Your own private struct that contains a pool pointer and any other data you want to use in the thread. 2) a pool pointer
// define your struct
typedef struct { switch_memory_pool_t *pool; int num; } my_helper_t;
// declare your variables
switch_memory_pool_t *pool; my_helper_t *mh;
// create pool switch_core_new_memory_pool(&pool);
// use the pool to create the struct
mh = (my_helper_t *) switch_core_alloc(pool, sizeof(*mh));
// populate the struct
mh->pool = pool; mh->num = 42;
// now pass mh as the private data of the thread and get it back in your thread. // just destroy the pool at the end of your function
static void *SWITCH_THREAD_FUNC my_thread(switch_thread_t *thread, void *obj) { my_helper_t *mh = (my_helper_t *) obj;
// Do your thang
switch_core_destroy_memory_pool(&mh->pool); mh = NULL; }
On Tue, Jun 16, 2009 at 9:28 AM, Kevin Snow <kevin.snow@ooma.com> wrote:
Hi,
I’m writing my own module and have a situation where I need to connect two endpoints in response to an event. I have the custom event tied into my module and I know my endpoints that I need to connect but it’s not clear to me how to set up this connection.
It appears that I cannot (or at least don’t want) to set up this connection on the thread the event came in on as that stalls other events from coming in. I think I need to create a new thread and session then use switch_ivr_originate and bridge the two. That however seems easier said than done, so I must be missing something.
Switch_thread_create looks fairly straight forward but in the examples of it they all are used in situations where a session already exists. It’s uses the pool from that session. In the event handler I don’t have any session. I need to set the entire phone call/session up from scratch. I keep looking for a “switch_create_session” like call to setup this but that doesn’t exist. Clearly I’m going about it wrong.
Are there any examples or docs on how to do this programmatically? I’ve search and can’t find anything like this.
I’m fairly new to FS but hopefully this isn’t a total newbie question and that it makes sense. I’m excited for ClueCon, that’ll shed a lot of light on FS for me.
Kevin
_______________________________________________ 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
FreeSWITCH http://www.freeswitch.org/ ClueCon http://www.cluecon.com/
AIM: anthm MSN:anthony_minessale@hotmail.com <MSN%3Aanthony_minessale@hotmail.com> GTALK/JABBER/PAYPAL:anthony.minessale@gmail.com<PAYPAL%3Aanthony.minessale@gmail.com> IRC: irc.freenode.net #freeswitch
FreeSWITCH Developer Conference sip:888@conference.freeswitch.org <sip%3A888@conference.freeswitch.org> iax:guest@conference.freeswitch.org/888 googletalk:conf+888@conference.freeswitch.org<googletalk%3Aconf%2B888@conference.freeswitch.org> pstn:213-799-1400
_______________________________________________ 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
I¹m working on a module in C and I¹ve hit a little bit of a stumbling block. I have a situation where I receive an event and in response I want to send a known session to a new dialplan eventhough it¹s somewhere in the middle of another dialplan. I can¹t find examples of doing this in C. Are there examples of doing this or am I going about this the wrong way. Thanks in advance! Kevin Snow
look for switch_ivr_session_transfer On Thu, Jul 9, 2009 at 5:36 PM, Kevin Snow <kevin.snow@ooma.com> wrote:
I’m working on a module in C and I’ve hit a little bit of a stumbling block. I have a situation where I receive an event and in response I want to send a known session to a new dialplan eventhough it’s somewhere in the middle of another dialplan. I can’t find examples of doing this in C.
Are there examples of doing this or am I going about this the wrong way.
Thanks in advance!
Kevin Snow
_______________________________________________ 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 FreeSWITCH http://www.freeswitch.org/ ClueCon http://www.cluecon.com/ Twitter: http://twitter.com/FreeSWITCH_wire AIM: anthm MSN:anthony_minessale@hotmail.com <MSN%3Aanthony_minessale@hotmail.com> GTALK/JABBER/PAYPAL:anthony.minessale@gmail.com<PAYPAL%3Aanthony.minessale@gmail.com> IRC: irc.freenode.net #freeswitch FreeSWITCH Developer Conference sip:888@conference.freeswitch.org <sip%3A888@conference.freeswitch.org> iax:guest@conference.freeswitch.org/888 googletalk:conf+888@conference.freeswitch.org<googletalk%3Aconf%2B888@conference.freeswitch.org> pstn:213-799-1400
If you are in an event you need to get a ptr to the session then use switch_ivr_session_transfer() Like: switch_core_session_t *session; const char *destination = "dest"; const char *dialplan = "XML"; const char *context = "default"; if ((session = switch_core_session_locate(uuid_here)) { /* The condition will catch race conditions where you get the event a couple milliseconds after the call has hung up */ switch_ivr_session_transfer(session, destination, dialplan, context); switch_core_session_rwunlock(session); } Definition: (in switch_ivr.h) /*! \brief Transfer an existing session to another location \param session the session to transfer \param extension the new extension \param dialplan the new dialplan (OPTIONAL, may be NULL) \param context the new context (OPTIONAL, may be NULL) */ SWITCH_DECLARE(switch_status_t) switch_ivr_session_transfer(_In_ switch_core_session_t *session, const char *extension, const char *dialplan, const char *context); Math On 9-Jul-09, at 6:36 PM, Kevin Snow wrote:
I’m working on a module in C and I’ve hit a little bit of a stumbling block. I have a situation where I receive an event and in response I want to send a known session to a new dialplan eventhough it’s somewhere in the middle of another dialplan. I can’t find examples of doing this in C.
Are there examples of doing this or am I going about this the wrong way.
Thanks in advance!
Kevin Snow
_______________________________________________ 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
Hi, I¹m writing a module where I have an inbound call and want to bridge this to multiple endpoints. Each of these destination endpoints will ring until one of them is answered. At this point I want to bridge to that endpoint and cancel the others to stop the ringing. What is the recommended way to do this in FS? I have the ring single endpoint (switch_ivr_originate) and bridge to that endpoint when answered working. I¹m trying to understand the multiple endpoint case now. It seems that I will need to create a new session for each endpoint. In each of these session threads I can then switch_ivr_originate to a single endpoint. Somehow, each endpoint will need to know about the others to cancel them when it¹s endpoint is answered. This could get tricky with lots of edge cases, is there a recommended way to accomplish this programmatically? Thanks Kevin Snow
You can use the same switch_ivr_originate code, in your dial string seperate the destinations with , or | depending on if you want them to ring all at once or in order one at a time. Mike On Jun 24, 2009, at 5:01 PM, Kevin Snow wrote:
Hi,
I’m writing a module where I have an inbound call and want to bridge this to multiple endpoints. Each of these destination endpoints will ring until one of them is answered. At this point I want to bridge to that endpoint and cancel the others to stop the ringing.
What is the recommended way to do this in FS?
I have the ring single endpoint (switch_ivr_originate) and bridge to that endpoint when answered working. I’m trying to understand the multiple endpoint case now.
It seems that I will need to create a new session for each endpoint. In each of these session threads I can then switch_ivr_originate to a single endpoint. Somehow, each endpoint will need to know about the others to cancel them when it’s endpoint is answered. This could get tricky with lots of edge cases, is there a recommended way to accomplish this programmatically?
This is too easy and seems to be working great! I¹m glad I asked before heading down the path I thought I had to venture. Thanks! K On 6/24/09 2:20 PM, "Michael Jerris" <mike@jerris.com> wrote:
You can use the same switch_ivr_originate code, in your dial string seperate the destinations with , or | depending on if you want them to ring all at once or in order one at a time.
Mike
On Jun 24, 2009, at 5:01 PM, Kevin Snow wrote:
Hi,
I¹m writing a module where I have an inbound call and want to bridge this to multiple endpoints. Each of these destination endpoints will ring until one of them is answered. At this point I want to bridge to that endpoint and cancel the others to stop the ringing.
What is the recommended way to do this in FS?
I have the ring single endpoint (switch_ivr_originate) and bridge to that endpoint when answered working. I¹m trying to understand the multiple endpoint case now.
It seems that I will need to create a new session for each endpoint. In each of these session threads I can then switch_ivr_originate to a single endpoint. Somehow, each endpoint will need to know about the others to cancel them when it¹s endpoint is answered. This could get tricky with lots of edge cases, is there a recommended way to accomplish this programmatically?
_______________________________________________ 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
On Wed, Jun 24, 2009 at 2:01 PM, Kevin Snow <kevin.snow@ooma.com> wrote:
Hi,
I’m writing a module where I have an inbound call and want to bridge this to multiple endpoints. Each of these destination endpoints will ring until one of them is answered. At this point I want to bridge to that endpoint and cancel the others to stop the ringing.
The originate and bridge commands support multiple-ring, first-answer-wins dialing: http://wiki.freeswitch.org/wiki/Misc._Dialplan_Tools_bridgecall#Description A comma-sep list of endpoints means simultaneous ring. (Pipe-delim means sequential ring.) HtH. BTW, what language are you using for your module? -MC
I¹m writing my module in C. Thanks Kevin On 6/24/09 2:21 PM, "Michael Collins" <msc@freeswitch.org> wrote:
On Wed, Jun 24, 2009 at 2:01 PM, Kevin Snow <kevin.snow@ooma.com> wrote:
Hi,
I¹m writing a module where I have an inbound call and want to bridge this to multiple endpoints. Each of these destination endpoints will ring until one of them is answered. At this point I want to bridge to that endpoint and cancel the others to stop the ringing.
The originate and bridge commands support multiple-ring, first-answer-wins dialing: http://wiki.freeswitch.org/wiki/Misc._Dialplan_Tools_bridgecall#Description
A comma-sep list of endpoints means simultaneous ring. (Pipe-delim means sequential ring.) HtH. BTW, what language are you using for your module? -MC
_______________________________________________ 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
participants (5)
-
Anthony Minessale
-
Kevin Snow
-
Mathieu Rene
-
Michael Collins
-
Michael Jerris