[Freeswitch-dev] getting a session pointer within an event handler
How can I get a session pointer within an event handler? I tried to extract the uuid from the event header and then I tried to locate the session using the uuid : static void my_event_handler(switch_event_t *event) { switch_assert(event); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "channel name : %s\n",switch_event_get_header_nil(event, "channel-name")); char* uuid = switch_event_get_header(event, "session-id"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "uuid : %s\n",uuid); switch_core_session_t *session; session = switch_core_session_locate(uuid); switch_assert(session); ... } But the uuid is always null. The events that I am binding my routine is for CHANNEL_CREATE (I tried CHANNEL_EXECUTE too, same result) -- ------------------------------------------- Apostolos Pantsiopoulos Kinetix Tele.com R & D email: regs@kinetix.gr -------------------------------------------
The name of the header is. Unique-ID On Fri, Jan 30, 2009 at 7:48 AM, Apostolos Pantsiopoulos <regs@kinetix.gr>wrote:
How can I get a session pointer within an event handler?
I tried to extract the uuid from the event header and then I tried to locate the session using the uuid :
static void my_event_handler(switch_event_t *event) {
switch_assert(event);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "channel name : %s\n",switch_event_get_header_nil(event, "channel-name"));
char* uuid = switch_event_get_header(event, "session-id");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "uuid : %s\n",uuid);
switch_core_session_t *session;
session = switch_core_session_locate(uuid);
switch_assert(session);
...
}
But the uuid is always null. The events that I am binding my routine is for CHANNEL_CREATE (I tried CHANNEL_EXECUTE too, same result)
-- ------------------------------------------- Apostolos Pantsiopoulos Kinetix Tele.com R & D email: regs@kinetix.gr -------------------------------------------
_______________________________________________ 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
Thanks! I copied the lower-case version from another module while searching the code. I wonder how that module works (?!) (mod_event_socket.c) Anthony Minessale wrote:
The name of the header is.
Unique-ID
On Fri, Jan 30, 2009 at 7:48 AM, Apostolos Pantsiopoulos <regs@kinetix.gr <mailto:regs@kinetix.gr>> wrote:
How can I get a session pointer within an event handler?
I tried to extract the uuid from the event header and then I tried to locate the session using the uuid :
static void my_event_handler(switch_event_t *event) {
switch_assert(event);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "channel name : %s\n",switch_event_get_header_nil(event, "channel-name"));
char* uuid = switch_event_get_header(event, "session-id");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "uuid : %s\n",uuid);
switch_core_session_t *session;
session = switch_core_session_locate(uuid);
switch_assert(session);
...
}
But the uuid is always null. The events that I am binding my routine is for CHANNEL_CREATE (I tried CHANNEL_EXECUTE too, same result)
-- ------------------------------------------- Apostolos Pantsiopoulos Kinetix Tele.com R & D email: regs@kinetix.gr <mailto:regs@kinetix.gr> -------------------------------------------
_______________________________________________ Freeswitch-dev mailing list Freeswitch-dev@lists.freeswitch.org <mailto: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 <mailto:MSN%3Aanthony_minessale@hotmail.com> GTALK/JABBER/PAYPAL:anthony.minessale@gmail.com <mailto:PAYPAL%3Aanthony.minessale@gmail.com> IRC: irc.freenode.net <http://irc.freenode.net> #freeswitch
FreeSWITCH Developer Conference sip:888@conference.freeswitch.org <mailto:sip%3A888@conference.freeswitch.org> iax:guest@conference.freeswitch.org/888 <http://iax:guest@conference.freeswitch.org/888> googletalk:conf+888@conference.freeswitch.org <mailto: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
-- ------------------------------------------- Apostolos Pantsiopoulos Kinetix Tele.com R & D email: regs@kinetix.gr -------------------------------------------
Apostolos Pantsiopoulos wrote:
Thanks! I copied the lower-case version from another module while searching the code. I wonder how that module works (?!) (mod_event_socket.c)
Because switch_event_get_header uses strcasecmp so it is case insensitive. The important thing is to use unique-id rather than session-id. Rob -- Rob Charlton Savage Minds Ltd
participants (3)
-
Anthony Minessale
-
Apostolos Pantsiopoulos
-
Rob Charlton