linux版本中间件

EslGateway.cpp 16KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550
  1. #include "EslGateway.h"
  2. #include "FsProxy.h"
  3. #include <thread>
  4. #include <iostream>
  5. #include <functional>
  6. #include <regex>
  7. #include <boost/algorithm/string.hpp>
  8. #include <boost/format.hpp>
  9. #include "Config.h"
  10. #include "Log.h"
  11. using Format = boost::format;
  12. //#pragma comment(lib,"libesl.a")
  13. CEslGateway::CEslGateway(CFsProxy * pParent) :m_pParent(pParent), m_Stop(true), m_EslHdl4Listen({ {0} }), m_EslHdl4Send({ {0} })
  14. {
  15. }
  16. CEslGateway::~CEslGateway()
  17. {
  18. }
  19. bool CEslGateway::start(void)
  20. {
  21. CConfig *cfg = CConfig::GetInstance();
  22. LOG_INFO(("{EslGateway}: 处理客户端连接, ip = %s,port=%d,pwd=%s"), cfg->fsAddr().c_str(), cfg->fsPort(), cfg->fsPwd().c_str());
  23. esl_connect(&m_EslHdl4Listen, cfg->fsAddr().c_str(), cfg->fsPort(), NULL, cfg->fsPwd().c_str());
  24. if (!m_EslHdl4Listen.connected)
  25. return false;
  26. LOG_INFO_S(("{EslGateway}: 处理客户端连接m_EslHdl4Listen OK"));
  27. esl_events(&m_EslHdl4Listen, ESL_EVENT_TYPE_PLAIN,
  28. "BACKGROUND_JOB CHANNEL_CREATE CHANNEL_PROGRESS CHANNEL_PROGRESS_MEDIA CHANNEL_ANSWER CHANNEL_HANGUP_COMPLETE CHANNEL_HOLD CHANNEL_UNHOLD DTMF CUSTOM sofia::register sofia::unregister callcenter::info");
  29. LOG_INFO(("{EslGateway}: 处理客户端连接, ip = %s,port=%d,pwd=%s"), cfg->fsAddr().c_str(), cfg->fsPort(), cfg->fsPwd().c_str());
  30. esl_connect(&m_EslHdl4Send, cfg->fsAddr().c_str(), cfg->fsPort(), NULL, cfg->fsPwd().c_str());
  31. if (!m_EslHdl4Send.connected)
  32. {
  33. esl_disconnect(&m_EslHdl4Listen);
  34. return false;
  35. }
  36. m_Stop = false;
  37. std::thread(std::bind(&CEslGateway::__eventThread,this)).detach();
  38. return true;
  39. }
  40. void CEslGateway::stop(void)
  41. {
  42. if (!m_Stop)
  43. {
  44. m_Stop = true;
  45. esl_disconnect(&m_EslHdl4Listen);
  46. esl_disconnect(&m_EslHdl4Send);
  47. }
  48. }
  49. bool CEslGateway::hangupAll(void)
  50. {
  51. return esl_send_recv(&m_EslHdl4Send, ESL_CMD_HANGUPALL) == ESL_SUCCESS;
  52. }
  53. bool CEslGateway::scanExten(void)
  54. {
  55. if (esl_send_recv(&m_EslHdl4Send, ESL_CMD_SCAN_INTERNAL) != ESL_SUCCESS)
  56. return false;
  57. if (m_EslHdl4Send.last_sr_event == nullptr || m_EslHdl4Send.last_sr_event->body == nullptr)
  58. return false;
  59. std::string body = m_EslHdl4Send.last_sr_event->body;
  60. std::list<std::string> rows;
  61. boost::split(rows, body, boost::is_any_of("\n"));
  62. while (!rows.empty())
  63. {
  64. std::string var = rows.front();
  65. rows.pop_front();
  66. std::regex space("\t| ");
  67. var = std::regex_replace(var, space, "");
  68. std::regex reg("IP:(.*)");
  69. if (std::regex_match(var, reg))
  70. {
  71. std::string extenNo, extenIP;
  72. extenIP = std::regex_replace(var, reg, "$1");
  73. while (!rows.empty())
  74. {
  75. var = rows.front();
  76. rows.pop_front();
  77. std::regex space("\t| ");
  78. var = std::regex_replace(var, space, "");
  79. reg = std::regex("Auth-User:(.*)");
  80. if (std::regex_match(var, reg))
  81. {
  82. extenNo = std::regex_replace(var, reg, "$1");
  83. if (!extenNo.empty() && !extenIP.empty())
  84. {
  85. LOG_DEBUG("分机注册:%s %s", extenNo.c_str(), extenIP.c_str());
  86. if(m_pParent)
  87. {
  88. m_pParent->onEslExtenReg(atoi(extenNo.c_str()), extenIP);
  89. }
  90. }
  91. break;
  92. }
  93. }
  94. }
  95. }
  96. return true;
  97. }
  98. bool CEslGateway::getAgentState(std::string AgentID, AgentDetail &agent)
  99. {
  100. Format fmt("api callcenter_config agent list %1%");
  101. fmt %AgentID;
  102. if (esl_send_recv(&m_EslHdl4Send, fmt.str().c_str()) != ESL_SUCCESS)
  103. return false;
  104. if (m_EslHdl4Send.last_sr_event == nullptr || m_EslHdl4Send.last_sr_event->body == nullptr)
  105. return false;
  106. std::string body = m_EslHdl4Send.last_sr_event->body;
  107. std::vector<std::string> rows;
  108. boost::split(rows, body, boost::is_any_of("\n"));
  109. if (rows.size() < 3)
  110. return false;
  111. std::map<std::string, std::string> mKeyVal;
  112. std::list<std::string> heards,contents;
  113. std::string heard = std::move(rows[0]);
  114. std::string content = std::move(rows[1]);
  115. boost::split(heards, heard, boost::is_any_of("|"));
  116. boost::split(contents, content, boost::is_any_of("|"));
  117. if(heards.size()!=contents.size())
  118. return false;
  119. while (!heards.empty())
  120. {
  121. mKeyVal[std::move(heards.front())] = std::move(contents.front());
  122. heards.pop_front();
  123. contents.pop_front();
  124. }
  125. //AgentDetail agent;
  126. auto name = mKeyVal.find("name");
  127. if (name != mKeyVal.end())
  128. agent.name = name->second;
  129. auto system = mKeyVal.find("system");
  130. if (system != mKeyVal.end())
  131. agent.system = system->second;
  132. auto uuid = mKeyVal.find("uuid");
  133. if (uuid != mKeyVal.end())
  134. agent.uuid = uuid->second;
  135. auto type = mKeyVal.find("type");
  136. if (type != mKeyVal.end())
  137. agent.type = type->second;
  138. auto contact = mKeyVal.find("contact");
  139. if (contact != mKeyVal.end())
  140. agent.contact = contact->second;
  141. auto status = mKeyVal.find("status");
  142. if (status != mKeyVal.end())
  143. agent.status = status->second;
  144. auto state = mKeyVal.find("state");
  145. if (state != mKeyVal.end())
  146. agent.state = state->second;
  147. return true;
  148. }
  149. bool CEslGateway::getConferenceMemberId(std::string MeetingId, std::string ChanId, std::string & MemberId)
  150. {
  151. std::string cmd;
  152. cmd = boost::str(Format("api conference %s list") % MeetingId);
  153. if (esl_send_recv(&m_EslHdl4Send, cmd.c_str()) != ESL_SUCCESS)
  154. return false;
  155. if (m_EslHdl4Send.last_sr_event && m_EslHdl4Send.last_sr_event->body) {
  156. std::vector<std::string> vs;
  157. boost::split(vs, m_EslHdl4Send.last_sr_event->body, boost::algorithm::is_any_of("\n"));
  158. for (auto v : vs) {
  159. if (v.find(ChanId) != std::string::npos) {
  160. std::vector<std::string> des;
  161. boost::split(des, v, boost::algorithm::is_any_of(";"));
  162. if (!des.empty()) {
  163. MemberId = des[0].c_str();
  164. return true;
  165. }
  166. break;
  167. }
  168. }
  169. }
  170. return false;
  171. }
  172. bool CEslGateway::delAgentAll(void)
  173. {
  174. LOG_DEBUG("清空FreeSWITCH中已签入坐席");
  175. Format fmt("api callcenter_config agent list");
  176. if (esl_send_recv(&m_EslHdl4Send, fmt.str().c_str()) != ESL_SUCCESS)
  177. return false;
  178. if (m_EslHdl4Send.last_sr_event == nullptr || m_EslHdl4Send.last_sr_event->body == nullptr)
  179. return false;
  180. std::string body = m_EslHdl4Send.last_sr_event->body;
  181. std::list<std::string> rows;
  182. boost::split(rows, body, boost::is_any_of("\n"));
  183. if (rows.size() < 3)
  184. return false;
  185. rows.pop_front();
  186. rows.pop_back();
  187. rows.pop_back();
  188. for (std::string &var : rows)
  189. {
  190. std::list<std::string> contents;
  191. boost::split(contents, var, boost::is_any_of("|"));
  192. std::string name = contents.front();
  193. delAgent(name);
  194. }
  195. return false;
  196. }
  197. bool CEslGateway::delAgent(std::string AgentID)
  198. {
  199. bool ret = true;
  200. std::string cmd;
  201. cmd = boost::str(Format("bgapi callcenter_config agent del %1% ") % AgentID);
  202. ret &= sendCmd(cmd);
  203. cmd = boost::str(Format("bgapi callcenter_config tier del ZXZ %1% ") % AgentID);
  204. ret &= sendCmd(cmd);
  205. return ret;
  206. }
  207. bool CEslGateway::delAgent(std::string AgentID, std::list<std::string> Groups)
  208. {
  209. bool ret = true;
  210. std::string cmd;
  211. cmd = boost::str(Format("bgapi callcenter_config agent del %1% ") % AgentID);
  212. ret &= sendCmd(cmd);
  213. for (std::string &var : Groups)
  214. {
  215. cmd = boost::str(Format("bgapi callcenter_config tier del %2% %1% ") % AgentID %var);
  216. ret &= sendCmd(cmd);
  217. }
  218. return ret;
  219. }
  220. bool CEslGateway::sendCmd(string pCmd)
  221. {
  222. LOG_DEBUG_S(pCmd);
  223. //esl_status_t Status = esl_send_recv(&m_EslHdl4Send, pCmd.c_str());
  224. esl_status_t Status = esl_send_recv_timed(&m_EslHdl4Send, pCmd.c_str(), 2000);
  225. if (Status != ESL_SUCCESS) {
  226. LOG_ERROR("执行失败: %d", Status);
  227. }
  228. return Status == ESL_SUCCESS;
  229. }
  230. std::string CEslGateway::getCmdResult(string pCmd)
  231. {
  232. if (esl_send_recv(&m_EslHdl4Send, pCmd.c_str()) != ESL_SUCCESS)
  233. return "";
  234. if (m_EslHdl4Send.last_sr_event == nullptr || m_EslHdl4Send.last_sr_event->body == nullptr)
  235. return "";
  236. std::string body = m_EslHdl4Send.last_sr_event->body;
  237. return body;
  238. }
  239. bool CEslGateway::execute(esl_handle_t * pHandle, const char * App, const char * Param)
  240. {
  241. if (pHandle == nullptr) return false;
  242. esl_status_t Status = esl_execute(pHandle, App, Param, NULL);
  243. return Status == ESL_SUCCESS;
  244. }
  245. bool CEslGateway::Execte(const char * App, const char * Param, const char * ChanId)
  246. {
  247. if (App == nullptr) return false;
  248. esl_status_t Status = esl_execute(&m_EslHdl4Send, App, Param, ChanId);
  249. return Status == ESL_SUCCESS;
  250. }
  251. void CEslGateway::__eventThread(void)
  252. {
  253. esl_event_t* pEvent = NULL;
  254. esl_handle_t* pListenHandle = &m_EslHdl4Listen;
  255. // 下面的设置保证执行同时多个APP时,后面的不会抢占前面的
  256. pListenHandle->event_lock = 1;
  257. while (!m_Stop)
  258. {
  259. // esl_recv_event会阻塞线程,其第二个参数为1,表示优先检查内部缓存列表,防止遗漏事件。
  260. if (esl_recv_event(pListenHandle, 1, NULL) == ESL_SUCCESS)
  261. {
  262. pEvent = pListenHandle->last_ievent;
  263. if (pEvent != NULL)
  264. __onEslEvent(pEvent);
  265. }
  266. else
  267. {
  268. // 连接中断
  269. __onEslDisconnect();
  270. return;
  271. }
  272. }
  273. }
  274. void CEslGateway::__onEslEvent(esl_event_t * pEvent)
  275. {
  276. /*char *pContent = new char[2048];
  277. esl_event_serialize(pEvent, &pContent, ESL_TRUE);
  278. LOG_DEBUG_S(pContent);
  279. FS_LINK_DELETE(pContent);*/
  280. switch ((uint32_t)pEvent->event_id)
  281. {
  282. case ESL_EVENT_BACKGROUND_JOB:
  283. __onEslEvtBgJobDone(pEvent);
  284. break;
  285. case ESL_EVENT_CHANNEL_CREATE:
  286. case ESL_EVENT_CHANNEL_ANSWER:
  287. case ESL_EVENT_CHANNEL_BRIDGE:
  288. case ESL_EVENT_CHANNEL_PROGRESS:
  289. case ESL_EVENT_CHANNEL_PROGRESS_MEDIA:
  290. case ESL_EVENT_CHANNEL_HANGUP_COMPLETE:
  291. __onEslEvtChanEvent(pEvent);
  292. break;
  293. case ESL_EVENT_DTMF:
  294. __onEslEvtDtmf(pEvent);
  295. break;
  296. case ESL_EVENT_CHANNEL_HOLD:
  297. __onEslEvtHold(pEvent, EVENT_HOLD);
  298. break;
  299. case ESL_EVENT_CHANNEL_UNHOLD:
  300. __onEslEvtHold(pEvent, EVENT_UNHOLD);
  301. break;
  302. case ESL_EVENT_CUSTOM:
  303. __onEslEvtCustom(pEvent);
  304. break;
  305. }
  306. }
  307. void CEslGateway::__onEslDisconnect(void)
  308. {
  309. LOG_WARN_S("{EslGateway}: 监听通道事件时连接中断");
  310. m_Stop = true;
  311. m_pParent->onEslDisconnect();
  312. }
  313. void CEslGateway::__onEslEvtBgJobDone(esl_event_t * pEvent)
  314. {
  315. BG_JOB_NOTIFY Notify;
  316. memset(&Notify, '\0', sizeof(BG_JOB_NOTIFY));
  317. char* HeaderValue = esl_event_get_header(pEvent, ESL_HEADER_JOB_UUID);
  318. if (HeaderValue != nullptr)
  319. Notify.JobInstance = atol(HeaderValue);
  320. LOG_DEBUG("JobCmd[%ld]-[%s]", Notify.JobInstance, HeaderValue);
  321. HeaderValue = esl_event_get_header(pEvent, ESL_HEADER_JOB_CMD);
  322. Notify.JobCmd = HeaderValue;
  323. HeaderValue = esl_event_get_body(pEvent);
  324. if (HeaderValue != nullptr)
  325. Notify.JobBody = HeaderValue;
  326. m_pParent->onEslEvtBgJobDone(&Notify);
  327. }
  328. void CEslGateway::__onEslEvtChanEvent(esl_event_t * pEvent)
  329. {
  330. CHAN_EVENT_NOTIFY Notify;
  331. char* HeaderValue = nullptr;
  332. // 获取事件ID
  333. Notify.EventId = (CHAN_EVENT_ID)pEvent->event_id;
  334. // 获取通道方向
  335. HeaderValue = esl_event_get_header(pEvent, ESL_HEADER_DIRECTION);
  336. if (strcmp(HeaderValue, ESL_HDR_DIRECTION_INBOUND) == 0)
  337. Notify.Direction = CALL_DIRECTION_INBOUND;
  338. else
  339. Notify.Direction = CALL_DIRECTION_OUTBOUND;
  340. // 获取会话ID
  341. HeaderValue = esl_event_get_header(pEvent, ESL_HEADER_CALLID);
  342. Notify.CallId = HeaderValue;
  343. HeaderValue = esl_event_get_header(pEvent, ESL_HEADER_CCID);
  344. if (HeaderValue != nullptr)
  345. Notify.CcId = HeaderValue;
  346. // 获取通道ID
  347. HeaderValue = esl_event_get_header(pEvent, ESL_HEADER_CHANID);
  348. Notify.ChanId = HeaderValue;
  349. // 获取主被叫
  350. HeaderValue = esl_event_get_header(pEvent, ESL_HEADER_CALLER);
  351. if(HeaderValue !=nullptr)
  352. Notify.Caller = HeaderValue;
  353. else
  354. {
  355. Format fmt("主叫号码未获取到,EventId = %d ,CallId = %s,ChanId = %s,Direction = %d,CcId = %s ");
  356. fmt %Notify.EventId % Notify.CallId % Notify.CallId % Notify.Direction % Notify.CcId;
  357. LOG_WARN_S(fmt.str());
  358. }
  359. HeaderValue = esl_event_get_header(pEvent, ESL_HEADER_CALLEE);
  360. if (HeaderValue != nullptr)
  361. {
  362. Notify.Callee = HeaderValue;
  363. regex reg("\\d+");
  364. if (!regex_match(HeaderValue, reg))
  365. {
  366. LOG_WARN("被叫号码为非存数字,软电话可能需要处理,分机号: %s", HeaderValue);
  367. HeaderValue = esl_event_get_header(pEvent, "variable_dialed_user"); //判断被叫号码是不是软电话,软电话获取的被叫不是真实注册的分机号,是随机字符串
  368. LOG_WARN("被叫号码为非存数字,软电话可能需要处理,分机号: %s", HeaderValue);
  369. }
  370. if(HeaderValue!=nullptr)
  371. Notify.Callee = HeaderValue;
  372. }
  373. else
  374. {
  375. HeaderValue = esl_event_get_header(pEvent, ESL_HEADER_DEST_NUM);
  376. if (HeaderValue != nullptr)
  377. Notify.Callee = HeaderValue;
  378. }
  379. // 获取操作类型 区分自动外呼
  380. HeaderValue = esl_event_get_header(pEvent, ESL_HEADER_CHAN_OP_TYPE);
  381. if (HeaderValue != nullptr)
  382. {
  383. LOG_DEBUG("%s=%s", ESL_HEADER_CHAN_OP_TYPE, HeaderValue);
  384. Notify.CallType = atoi(HeaderValue);
  385. }
  386. // 获取自动外呼任务id ,
  387. HeaderValue = esl_event_get_header(pEvent, ESL_HEADER_CHAN_TASK_ID);
  388. if (HeaderValue != nullptr)
  389. {
  390. LOG_DEBUG("%s=%s", ESL_HEADER_CHAN_TASK_ID, HeaderValue);
  391. Notify.TaskId = atol(HeaderValue);
  392. }
  393. // 代码外呼,自动外呼时,主叫create事件时就得到正确的被叫
  394. HeaderValue = esl_event_get_header(pEvent, ESL_HEADER_CHAN_MALL_CALL_CALLEE);
  395. if (HeaderValue != nullptr)
  396. {
  397. LOG_DEBUG("%s=%s", ESL_HEADER_CHAN_MALL_CALL_CALLEE, HeaderValue);
  398. Notify.Called = HeaderValue;
  399. }
  400. // 获取挂机原因
  401. HeaderValue = esl_event_get_header(pEvent, ESL_HEADER_HANGUP_CAUSE);
  402. if (HeaderValue != nullptr)
  403. Notify.HangupCause = HeaderValue;
  404. else
  405. {
  406. HeaderValue = esl_event_get_header(pEvent, ESL_HEADER_CALL_FAILED_CAUSE);
  407. if (HeaderValue != nullptr)
  408. Notify.HangupCause = HeaderValue;
  409. }
  410. // 获取通道操作标识
  411. HeaderValue = esl_event_get_header(pEvent, ESL_HEADER_CHAN_OP_INSTANCE);
  412. if (HeaderValue != nullptr)
  413. {
  414. LOG_DEBUG("%s=%s", ESL_HEADER_CHAN_OP_INSTANCE,HeaderValue);
  415. Notify.ChanOpInstance = atol(HeaderValue);
  416. }
  417. Format fmt("FreeSWITCH事件,EventId = %d ,CallId = %s,ChanId = %s,Direction = %d ,caller = %s,callee = %s , op_type = %d,op_instance = %ld,task_id = %ld,call_called = %s");
  418. fmt %Notify.EventId % Notify.CallId % Notify.ChanId % Notify.Direction % Notify.Caller % Notify.Callee % Notify.CallType % Notify.ChanOpInstance %Notify.TaskId %Notify.Called;
  419. LOG_DEBUG(fmt.str());
  420. m_pParent->onEslEvtChannel(&Notify);
  421. }
  422. void CEslGateway::__onEslEvtCustom(esl_event_t * pEvent)
  423. {
  424. char* HeaderValue = nullptr;
  425. HeaderValue = esl_event_get_header(pEvent, ESL_HEADER_SUBCLASS);
  426. if (strcmp(HeaderValue, ESL_HDR_SUBCLASS_SIP_REG) == 0) // 分机注册事件
  427. {
  428. HeaderValue = esl_event_get_header(pEvent, ESL_HEADER_EXTEN_NO);
  429. uint32_t ExtenNo = 0;
  430. sscanf(HeaderValue, "%u", &ExtenNo);
  431. m_pParent->onEslExtenReg(ExtenNo,"");
  432. }
  433. else if (strcmp(HeaderValue, ESL_HDR_SUBCLASS_SIP_UNREG) == 0) // 分机注销事件
  434. {
  435. HeaderValue = esl_event_get_header(pEvent, ESL_HEADER_EXTEN_NO);
  436. uint32_t ExtenNo = 0;
  437. if (HeaderValue != NULL) // jssip软电话注册后,刷新页面得到的HeaderValue为空,导致sscanf_s失败
  438. {
  439. sscanf(HeaderValue, "%u", &ExtenNo);
  440. m_pParent->onEslExtenUnreg(ExtenNo);
  441. }
  442. }
  443. else if (strcmp(HeaderValue, "callcenter::info") == 0) {
  444. const char* queueName = esl_event_get_header(pEvent, "CC-Queue");
  445. const char* callsWaitingStr = esl_event_get_header(pEvent, "CC-Count");
  446. if (callsWaitingStr) {
  447. LOG_INFO("队列[%s]当前排队人数[%s]", queueName, callsWaitingStr);
  448. m_pParent->onCallcenterQueue(queueName, callsWaitingStr);
  449. }
  450. char *pContent = new char[2048];
  451. esl_event_serialize(pEvent, &pContent, ESL_TRUE);
  452. LOG_DEBUG_S(pContent);
  453. FS_LINK_DELETE(pContent);
  454. }
  455. }
  456. void CEslGateway::__onEslEvtDtmf(esl_event_t * pEvent)
  457. {
  458. DTMF_NOTIFY Notify;
  459. char* HeaderValue = NULL;
  460. // 获取会话ID
  461. HeaderValue = esl_event_get_header(pEvent, ESL_HEADER_CALLID);
  462. Notify.CallId = HeaderValue;
  463. // 获取通道ID
  464. HeaderValue = esl_event_get_header(pEvent, ESL_HEADER_CHANID);
  465. Notify.ChanId = HeaderValue;
  466. // 获取DTMF
  467. HeaderValue = esl_event_get_header(pEvent, ESL_HEADER_DTMF);
  468. Notify.DTMF = HeaderValue;
  469. m_pParent->onEslEvtDtmf(&Notify);
  470. }
  471. void CEslGateway::__onEslEvtHold(esl_event_t * pEvent, EVENT_HOLD_TYPE EvtType)
  472. {
  473. HOLD_NOTIFY Notify;
  474. char* HeaderValue = NULL;
  475. // 获取会话ID
  476. HeaderValue = esl_event_get_header(pEvent, ESL_HEADER_CALLID);
  477. Notify.CallId = HeaderValue;
  478. // 获取通道ID
  479. HeaderValue = esl_event_get_header(pEvent, ESL_HEADER_CHANID);
  480. Notify.ChanId = HeaderValue;
  481. // 获取保持事件类型
  482. Notify.EvtType = EvtType;
  483. m_pParent->onEslEvtHold(&Notify);
  484. }