[Freeswitch-users] Event_handler using switch_event_bind and private user data issue
Jon Lederman
jon at thesoniccloud.com
Thu Jul 18 06:09:17 MSD 2013
Hi,
I'm trying to set up an event handler that will send some user data to a callback function. I am using:
pvt = (switch_audio_weaver_t*) switch_core_session_alloc(session, sizeof(*pvt));
if (switch_event_bind(modname, SWITCH_EVENT_CUSTOM, AUDIOWEAVER_SEND_MESSAGE, audioweaver_message_event_handler, pvt) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_FALSE;
}
This works fine and my event handler is called. But, I am unclear how to get the event_user_data. My event handler is:
static void audioweaver_message_event_handler(switch_event_t *event)
{
switch_audio_weaver_t *pvt = (switch_audio_weaver_t *) event->event_user_data;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "AudioWeaver Message Event Handler Reached!");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, switch_event_get_body(event));
std::string reply;
int ret = pvt->aw_talker->SendMessage("set_value,Sine1.freq,110.0", reply);
I am using mod_event_socket, which uses switch_event_fire. I note in switch_event.h, the following:
/*!
\brief Fire an event filling in most of the arguements with obvious values
\param event the event to send (will be nulled on success)
\return SWITCH_STATUS_SUCCESS if the operation was successful
\note the body supplied by this function will supersede an existing body the event may have
*/
#define switch_event_fire(event) switch_event_fire_detailed(__FILE__, (const char * )__SWITCH_FUNC__, __LINE__, event, NULL)
/*!
How would I use switch_event_fire_detailed with mod_event_socket, which I believe is necessary in order to send the user_data?
}
However, the pointer doesn't seem to point to the private data. Am I setting up my event handler correctly to get this data?
Thanks.
-Jon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20130717/9eab92a4/attachment-0001.html
Join us at ClueCon 2011 Aug 9-11, 2011
More information about the FreeSWITCH-users
mailing list