[Freeswitch-dev] Originating from an event.

Michael Collins msc at freeswitch.org
Tue Jun 16 09:45:19 PDT 2009


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 at 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 at 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 at 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 at hotmail.com <MSN%3Aanthony_minessale at hotmail.com>
> GTALK/JABBER/PAYPAL:anthony.minessale at gmail.com<PAYPAL%3Aanthony.minessale at gmail.com>
> IRC: irc.freenode.net #freeswitch
>
> FreeSWITCH Developer Conference
> sip:888 at conference.freeswitch.org <sip%3A888 at conference.freeswitch.org>
> iax:guest at conference.freeswitch.org/888
> googletalk:conf+888 at conference.freeswitch.org<googletalk%3Aconf%2B888 at conference.freeswitch.org>
> pstn:213-799-1400
>
> _______________________________________________
> Freeswitch-dev mailing list
> Freeswitch-dev at lists.freeswitch.org
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev
> http://www.freeswitch.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-dev/attachments/20090616/a5ea84e9/attachment.html 


More information about the Freeswitch-dev mailing list