书接上文,已经完成了模块的加载工作,为了使模块真正的有点作用,试图从模块中新增功能并加载到服务,使用api可以实现电话拨出。
在mod_book.c中,编辑如下:
#include<switch.h>
SWITCH_MODULE_LOAD_FUNCTION(mod_book_load);
SWITCH_MODULE_DEFINITION(mod_book,mod_book_load,NULL,NULL);
SWITCH_STANDARD_DIALPLAN(book_dialplan_hunt)
{
switch_caller_extension_t *extension = NULL;
switch_channel_t *channel = switch_core_session_get_channel(session);
if(!caller_profile) {
caller_profile = switch_channel_get_caller_profile(channel);
}
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session),SWITCH_LOG_INFO,
"Procession %s <%s>->%s in context %s\n",
caller_profile->caller_id_name,caller_profile->caller_id_number,
caller_profile->destination_number,caller_profile->context);
extension = switch_caller_extension_new(session,"book","book");
if(!extension) abort();
switch_caller_extension_add_application(session,extension,
"lo