[Freeswitch-users] Event_handler using switch_event_bind and private user data issue
Steven Ayre
steveayre at gmail.com
Thu Jul 18 19:00:40 MSD 2013
>
> /*!
> \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 at 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 at freeswitch.org
> http://www.freeswitchsolutions.com
>
>
>
>
> Official FreeSWITCH Sites
> http://www.freeswitch.org
> http://wiki.freeswitch.org
> http://www.cluecon.com
>
> FreeSWITCH-users mailing list
> FreeSWITCH-users at lists.freeswitch.org
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
> http://www.freeswitch.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20130718/3f4c326f/attachment.html
Join us at ClueCon 2011 Aug 9-11, 2011
More information about the FreeSWITCH-users
mailing list