mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-10-31 15:44:21 +00:00
add optional arg to hangup hook in perl/lua
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8323 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
1 parent
de516ce25f
commit
385528394e
7 files changed
+389
-12
No files matched your search
@@ -4,7 +4,7 @@
|
||||
|
||||
static STRLEN n_a;
|
||||
|
||||
#define init_me() cb_function = hangup_func_str = NULL; hh = mark = 0; my_perl = NULL; cb_arg = NULL
|
||||
#define init_me() cb_function = hangup_func_str = NULL; hangup_func_arg = NULL; hh = mark = 0; my_perl = NULL; cb_arg = NULL
|
||||
|
||||
Session::Session() : CoreSession()
|
||||
{
|
||||
@@ -26,6 +26,7 @@ Session::~Session()
|
||||
switch_safe_free(cb_function);
|
||||
switch_safe_free(cb_arg);
|
||||
switch_safe_free(hangup_func_str);
|
||||
switch_safe_free(hangup_func_arg);
|
||||
switch_core_event_hook_remove_state_change(session, perl_hanguphook);
|
||||
}
|
||||
|
||||
@@ -82,7 +83,12 @@ void Session::do_hangup_hook()
|
||||
return;
|
||||
}
|
||||
|
||||
code = switch_mprintf("%s(%s)", hangup_func_str, hook_state == CS_HANGUP ? "hangup" : "transfer");
|
||||
if (hangup_func_arg) {
|
||||
code = switch_mprintf("%s(%s,%s)", hangup_func_str, hook_state == CS_HANGUP ? "hangup" : "transfer", hangup_func_arg);
|
||||
} else {
|
||||
code = switch_mprintf("%s(%s)", hangup_func_str, hook_state == CS_HANGUP ? "hangup" : "transfer");
|
||||
}
|
||||
|
||||
Perl_eval_pv(my_perl, code, TRUE);
|
||||
free(code);
|
||||
}
|
||||
@@ -105,7 +111,7 @@ static switch_status_t perl_hanguphook(switch_core_session_t *session_hungup)
|
||||
}
|
||||
|
||||
|
||||
void Session::setHangupHook(char *func) {
|
||||
void Session::setHangupHook(char *func, char *arg) {
|
||||
|
||||
sanity_check_noreturn;
|
||||
|
||||
@@ -116,6 +122,9 @@ void Session::setHangupHook(char *func) {
|
||||
switch_channel_set_private(channel, "CoreSession", this);
|
||||
hook_state = switch_channel_get_state(channel);
|
||||
switch_core_event_hook_add_state_change(session, perl_hanguphook);
|
||||
if (arg) {
|
||||
hangup_func_arg = strdup(func);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user