/*! \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?
switch_event.h:418:#define switch_event_fire_data(event, data) switch_event_fire_detailed(__FILE__, (const char * )__SWITCH_FUNC__, __LINE__, event, data) So probably switch_event_fire_data(event_name, user_data) On 18 July 2013 03:09, Jon Lederman <jon@thesoniccloud.com> wrote:
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
_________________________________________________________________________ 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