mod_counterconnector.cpp 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984
  1. /////////////////////////////////
  2. ///// 连线服务
  3. /////////////////////////////////
  4. #include "stdafx.h"
  5. #include "ListEntry.h"
  6. #include "Event.h"
  7. #include "mod_counterconnector.h"
  8. #include "CounterConnector_msg_g.h"
  9. #include "../mod_interactivecontrol/Event.h"
  10. #include "../mod_mediacontroller/Event.h"
  11. #include "../mod_sipphone/Event.h"
  12. #include "../mod_evtconverter/Event.h"
  13. using namespace CounterConnector;
  14. void CCounterConnectorEntity ::OnPreStart(CAutoArray<CSimpleStringA> strArgs,CSmartPointer<ITransactionContext> pTransactionContext)
  15. {
  16. ErrorCodeEnum Error = __OnStart(Error_Succeed);
  17. CSmartPointer<IEntityFunction> spFunction = GetFunction();
  18. pTransactionContext->SendAnswer(Error);
  19. }
  20. void CCounterConnectorEntity ::OnPreClose(EntityCloseCauseEnum eCloseCause,CSmartPointer<ITransactionContext> pTransactionContext)
  21. {
  22. ErrorCodeEnum Error = __OnClose(Error_Succeed);
  23. pTransactionContext->SendAnswer(Error);
  24. }
  25. void CCounterConnectorEntity ::OnSelfTest(EntityTestEnum eTestType,CSmartPointer<ITransactionContext> pTransactionContext)
  26. {
  27. if (Test_ShakeHand == eTestType)
  28. {
  29. pTransactionContext->SendAnswer(Error_Succeed);
  30. }
  31. }
  32. ErrorCodeEnum CCounterConnectorEntity ::__OnStart(ErrorCodeEnum preOperationError)
  33. {
  34. if (preOperationError != Error_Succeed) {
  35. return preOperationError;
  36. }
  37. //MessageBoxA(0, 0, 0, 0);
  38. //is Pad Version
  39. m_pCurrentSession = NULL;
  40. m_bIsSalesRecord = false;
  41. m_bIsRemoteRecord = false;
  42. m_bHasLaunched = false;
  43. CSmartPointer<IEntityFunction> spFunction = GetFunction();
  44. CSystemStaticInfo stStaticinfo;
  45. spFunction->GetSystemStaticInfo(stStaticinfo);
  46. m_fsm.Init(this);
  47. int i = 0;
  48. m_arrListener.Init(20);
  49. spFunction->SubscribeLog(m_arrListener[i++], this, Log_Event, Severity_None, Error_IgnoreAll, EVENT_MOD_CONNECT_PICKUP_CALL,NULL,false);
  50. spFunction->SubscribeLog(m_arrListener[i++], this, Log_Event, Severity_None, Error_IgnoreAll, EVENT_MOD_CONNECT_HANDFREE_CALL,NULL,false);
  51. spFunction->SubscribeLog(m_arrListener[i++], this, Log_Event, Severity_None, Error_IgnoreAll, EVENT_MOD_CONNECT_HANDFREE_TO_PICKUP);
  52. spFunction->SubscribeLog(m_arrListener[i++], this, Log_Event, Severity_None, Error_IgnoreAll, EVENT_MOD_CONNECT_PICKUP_TO_HANDFREE);
  53. spFunction->SubscribeLog(m_arrListener[i++], this, Log_Event, Severity_None, Error_IgnoreAll, EVENT_MOD_CONNECT_HANGUP);
  54. spFunction->SubscribeLog(m_arrListener[i++], this, Log_Event, Severity_None, Error_IgnoreAll, EVENT_MOD_CONNECT_HANGUP_BY_CONNECTING);
  55. spFunction->SubscribeLog(m_arrListener[i++], this, Log_Event, Severity_None, Error_IgnoreAll, EVENT_MOD_CONNECT_HANGUP_BY_AGENT);
  56. spFunction->SubscribeLog(m_arrListener[i++], this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_PICKUP);
  57. spFunction->SubscribeLog(m_arrListener[i++], this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_ONHOOK);
  58. spFunction->SubscribeLog(m_arrListener[i++], this, Log_Event, Severity_None, Error_IgnoreAll, EVENT_MOD_CONNECT_AGENT_HANDFREE_PICKUP);
  59. spFunction->SubscribeLog(m_arrListener[i++], this, Log_Event, Severity_None, Error_IgnoreAll, EVENT_MOD_CONNECT_AGENT_PICKUP_HANDFREE);
  60. spFunction->SubscribeLog(m_arrListener[i++], this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_MOD_ASSISCHAN_STARTED_SUCCESS);
  61. spFunction->SubscribeLog(m_arrListener[i++], this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_MOD_SIPPHONE_STARTED_SUCCESS);
  62. spFunction->SubscribeLog(m_arrListener[i++], this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_UI_RETURNMENU,NULL,false);
  63. spFunction->SubscribeLog(m_arrListener[i++], this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_UI_STARTPHOTOGRAPH,NULL,false);
  64. spFunction->SubscribeLog(m_arrListener[i++], this, Log_Event, Severity_None, Error_IgnoreAll, EVENT_MOD_CONNECT_STOP_RECORD_BROADCAST,NULL,false);
  65. spFunction->SubscribeLog(m_arrListener[i++], this, Log_Event, Severity_None, Error_IgnoreAll, EVENT_MOD_CONNECT_BEGAIN_RECORD_CALL,NULL,false);
  66. spFunction->SubscribeLog(m_arrListener[i++], this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_UI_STARTREMOTERECORD,NULL,false);
  67. spFunction->SubscribeLog(m_arrListener[i++], this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_UI_STOPREMOTERECORD,NULL,false);
  68. spFunction->SubscribeLog(m_arrListener[i++], this, Log_Event, Severity_None, Error_IgnoreAll, EVENT_MOD_SIP_GET_VIDEO_FAILED, NULL, false);
  69. spFunction->RegistSysVarEvent("UIState", this);
  70. return Error_Succeed;
  71. }
  72. void CCounterConnectorEntity::OnStarted()
  73. {
  74. CSimpleStringA uiState;
  75. GetFunction()->GetSysVar("UIState", uiState);
  76. if (uiState.GetLength() > 0 && uiState[0] == 'M'){
  77. if (false == m_bHasLaunched) {
  78. m_bHasLaunched = true;
  79. }
  80. }
  81. Sleep(500);
  82. m_pCounterConnectorChannel = new ChannelCounterConnectorClient(this);
  83. if (Error_Succeed == ConnectAssistChannel()){
  84. m_bConnectAssist = true;
  85. }
  86. else {
  87. GetFunction()->SetTimer(1, this, 3600);
  88. }
  89. if (m_fsm.ReConnectionAssistchan()){
  90. m_fsm.m_bConAssist = true;
  91. }
  92. else {
  93. GetFunction()->SetTimer(2, this, 3900);
  94. }
  95. Sleep(500);
  96. if (m_fsm.ReConnectionSipphone()){
  97. m_fsm.m_bConSipphone = true;
  98. }
  99. else {
  100. GetFunction()->SetTimer(3, this, 3700);
  101. }
  102. m_fsm.ReConnectionSyncService();
  103. }
  104. ErrorCodeEnum CCounterConnectorEntity::ConnectAssistChannel()
  105. {
  106. if (NULL == m_pCounterConnectorChannel) {
  107. m_pCounterConnectorChannel = new ChannelCounterConnectorClient(this);
  108. }
  109. ErrorCodeEnum Error = m_pCounterConnectorChannel->Connect();
  110. if (Error != Error_Succeed) {
  111. LogWarn(Severity_Low, Error_Debug, EVENT_MOD_CONNECT_ASSIST_ERROR, "connect assistant channel error");
  112. #ifdef RVC_OS_WIN
  113. m_pCounterConnectorChannel->SafeDelete();
  114. #endif
  115. m_pCounterConnectorChannel = NULL;
  116. return Error;
  117. }
  118. {
  119. ChannelService_BeginState_Sub Sub;
  120. Error = m_pCounterConnectorChannel->BeginState(Sub);
  121. if (Error != Error_Succeed){
  122. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("BeginState biz channel failed!");
  123. m_pCounterConnectorChannel->GetFunction()->CloseSession();
  124. #ifdef RVC_OS_WIN
  125. m_pCounterConnectorChannel->SafeDelete();
  126. #endif
  127. m_pCounterConnectorChannel = NULL;
  128. return Error;
  129. }
  130. }
  131. {
  132. ChannelService_BeginRecv_Sub Sub;
  133. Sub.type = ACM_TYPE_DEVICE;
  134. Error = m_pCounterConnectorChannel->BeginRecv(Sub);
  135. if (Error != Error_Succeed) {
  136. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Begin BeginRecv ACM_TYPE_DEVICE failed!");
  137. m_pCounterConnectorChannel->GetFunction()->CloseSession();
  138. #ifdef RVC_OS_WIN
  139. m_pCounterConnectorChannel->SafeDelete();
  140. #endif
  141. m_pCounterConnectorChannel = NULL;
  142. return Error;
  143. }
  144. }
  145. {
  146. ChannelService_BeginRecv_Sub Sub;
  147. Sub.type = ACM_TYPE_AGENTVIDEOTYPE;
  148. Error = m_pCounterConnectorChannel->BeginRecv(Sub);
  149. if (Error != Error_Succeed){
  150. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Begin BeginRecv ACM_TYPE_AGENTVIDEOTYPE failed!");
  151. m_pCounterConnectorChannel->GetFunction()->CloseSession();
  152. #ifdef RVC_OS_WIN
  153. m_pCounterConnectorChannel->SafeDelete();
  154. #endif
  155. m_pCounterConnectorChannel = NULL;
  156. return Error;
  157. }
  158. }
  159. {
  160. ChannelService_BeginRecv_Sub Sub;
  161. Sub.type = ACM_TYPE_CALLTRANS;
  162. Error = m_pCounterConnectorChannel->BeginRecv(Sub);
  163. if (Error != Error_Succeed){
  164. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Begin BeginRecv ACM_TYPE_CALLTRANS failed!");
  165. m_pCounterConnectorChannel->GetFunction()->CloseSession();
  166. #ifdef RVC_OS_WIN
  167. m_pCounterConnectorChannel->SafeDelete();
  168. #endif
  169. m_pCounterConnectorChannel = NULL;
  170. return Error;
  171. }
  172. }
  173. return Error;
  174. }
  175. void CCounterConnectorEntity::OnSysVarEvent(const char *pszKey, const char *pszValue,const char *pszOldValue,const char *pszEntityName)
  176. {
  177. if (_stricmp(pszKey, "UIState") == 0)
  178. {
  179. if (pszValue[0] == 'M')
  180. {
  181. if (false == m_bHasLaunched){
  182. m_bHasLaunched = true;
  183. }
  184. }
  185. }
  186. }
  187. ErrorCodeEnum CCounterConnectorEntity::SetCallRouteParams(CSimpleStringA strQueueName, CSimpleStringA strClientLevel)
  188. {
  189. ErrorCodeEnum Error = Error_Succeed;
  190. m_fsm.m_strQueueName = strQueueName;
  191. m_fsm.m_strAddClientLevel = strClientLevel;
  192. return Error;
  193. }
  194. void CCounterConnectorEntity::HandlePickUpCallEvent()
  195. {
  196. PickUpCallMsg evt;
  197. evt.infos = "pickup call";
  198. SpSendBroadcast(GetFunction(), SP_MSG_OF(PickUpCallMsg), SP_MSG_SIG_OF(PickUpCallMsg), evt);
  199. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("SpSendBroadcast PickUpCallMsg to UI.");
  200. }
  201. void CCounterConnectorEntity::HandleGetVideoFailedEvent()
  202. {
  203. MediaService_ClientBase* pMSClient = new MediaService_ClientBase(this);
  204. CSimpleStringA strCustomerBeing("");
  205. GetFunction()->GetSysVar("CustomerBeing", strCustomerBeing);
  206. CSimpleStringA strCustomerHandle("");
  207. GetFunction()->GetSysVar("CustomerHandle", strCustomerHandle);
  208. CSimpleStringA strCameraState("");
  209. GetFunction()->GetSysVar(SYSVAR_CAMERASTATE, strCameraState);
  210. CSimpleStringA strmsg("");
  211. CSimpleStringA strinfo("");
  212. if (pMSClient->Connect() != Error_Succeed){
  213. strmsg = CSimpleStringA::Format("connect mediacontroller entity failed");
  214. pMSClient->SafeDelete();
  215. pMSClient = NULL;
  216. DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setResultCode("RTA3408")("连线接通时媒体资源控制实体状态异常");
  217. }
  218. else{
  219. strmsg = CSimpleStringA::Format("connect mediacontroller entity success");
  220. pMSClient->GetFunction()->CloseSession();
  221. pMSClient->SafeDelete();
  222. pMSClient = NULL;
  223. DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setResultCode("RTA3409")("连线接通时摄像头故障");
  224. }
  225. strinfo = CSimpleStringA::Format("%s, and CustomerBeing is %s, CustomerHandle is %s, CameraState is %s.", strmsg, strCustomerBeing.GetData(), strCustomerHandle.GetData(), strCameraState.GetData());
  226. LogWarn(Severity_Low, Error_Debug, LOG_WARN_COUNTERCONNECT_GET_VIDEO_FAILED_INFO, strinfo.GetData());
  227. }
  228. void CCounterConnectorEntity::HandlePickUpMicroPhoneEvent(int iEvent, const char* strMsg)
  229. {
  230. PickUpMicroPhoneEvt evt;
  231. evt.state = iEvent;
  232. evt.infos = strMsg;
  233. SpSendBroadcast(GetFunction(), SP_MSG_OF(PickUpMicroPhoneEvt), SP_MSG_SIG_OF(PickUpMicroPhoneEvt), evt);
  234. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("%s", strMsg);
  235. }
  236. ErrorCodeEnum CCounterConnectorEntity ::__OnClose(ErrorCodeEnum preOperationError)
  237. {
  238. if (preOperationError != Error_Succeed) {
  239. return preOperationError;
  240. }
  241. CSmartPointer<IEntityFunction> spFunction = GetFunction();
  242. for (int i = 0; i < m_arrListener.GetCount(); ++i) {
  243. spFunction->UnsubscribeLog(m_arrListener[i]);
  244. }
  245. spFunction->UnregistSysVarEvent("UIState");
  246. m_arrListener.Clear();
  247. m_fsm.PostEventFIFO(new FSMEvent(USER_EVT_EXIT));
  248. return Error_Succeed;
  249. }
  250. void CCounterConnectorEntity ::OnLog(const CAutoArray<CUUID> &SubIDs, const CUUID nLogID,const LogTypeEnum eLogType, const SeverityLevelEnum eLevel,
  251. const DWORD dwSysError,const DWORD dwUserCode,const DWORD dwEntityInstanceID, const WORD wEntityDevelID,
  252. const CAutoArray<DWORD> &Param, const char *pszEntityName, const char *pszModuleName,const char *pszMessage, const linkContext &pLinkInfo)
  253. {
  254. switch (dwUserCode)
  255. {
  256. case LOG_EVT_PICKUP:
  257. {
  258. m_fsm.m_bHandFree = false;
  259. if (!m_fsm.m_bIsAgentControl)
  260. {
  261. m_fsm.m_bAgentHandFree = false;
  262. }
  263. CSimpleStringA strValue;
  264. GetFunction()->GetSysVar("CallState", strValue);
  265. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("摘机,and CallState is %s.", strValue.GetData());
  266. HandlePickUpMicroPhoneEvent(1, "pick up microphone.");
  267. }
  268. break;
  269. case LOG_EVT_ONHOOK:
  270. {
  271. m_fsm.m_bHandFree = true;
  272. if (!m_fsm.m_bIsAgentControl)
  273. {
  274. m_fsm.m_bAgentHandFree = true;
  275. }
  276. CSimpleStringA strValue;
  277. GetFunction()->GetSysVar("CallState", strValue);
  278. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("挂机,and CallState is %s.", strValue.GetData());
  279. HandlePickUpMicroPhoneEvent(0, "hang up microphone.");
  280. }
  281. break;
  282. case EVENT_MOD_CONNECT_PICKUP_CALL: // 提机呼叫
  283. {
  284. bool brenderstate = m_fsm.IsCameraRenderState();
  285. if (m_bHasLaunched && !brenderstate){
  286. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("提机呼叫");
  287. HandlePickUpCallEvent();
  288. }
  289. else{
  290. if (!m_bHasLaunched) {
  291. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("UI has not launched, ignore it.");
  292. }
  293. if (brenderstate) {
  294. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Is camera render now, ignore it.");
  295. }
  296. }
  297. }
  298. break;
  299. case EVENT_MOD_CONNECT_HANDFREE_CALL: // 免提呼叫
  300. m_fsm.m_bNeedQueueName = true;
  301. if (m_fsm.m_bHandFree)
  302. {
  303. LogEvent(Severity_Middle,EVENT_MOD_CONNECT_SLV_HANDFREECALL,"handfree call");
  304. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("界面拨号,免提呼叫");
  305. if (pszMessage && strlen(pszMessage) > 0 && isdigit(pszMessage[0]))
  306. {
  307. char tmp[32] = {0};
  308. int i = 0;
  309. const char *p = pszMessage;
  310. while (isdigit(*p) && i < 30) {
  311. tmp[i++] = *p++;
  312. }
  313. tmp[i] = 0;
  314. m_fsm.m_strHintCallNum = tmp;
  315. }
  316. else
  317. {
  318. m_fsm.m_strHintCallNum = "";
  319. }
  320. //DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("recv UI call num = %s",m_fsm.m_strHintCallNum.GetData());
  321. m_fsm.PostEventFIFO(new FSMEvent(USER_EVT_HANDFREE_CALL));
  322. }
  323. else
  324. {
  325. LogEvent(Severity_Middle,EVENT_MOD_CONNECT_SLV_PICKUPCALL,"from hand free to pickup call because pickup");
  326. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("界面拨号,话筒呼叫");
  327. if (pszMessage && strlen(pszMessage) > 0 && isdigit(pszMessage[0]))
  328. {
  329. char tmp[32];
  330. int i = 0;
  331. const char *p = pszMessage;
  332. while (isdigit(*p) && i < 30) {
  333. tmp[i++] = *p++;
  334. }
  335. tmp[i] = 0;
  336. m_fsm.m_strHintCallNum = tmp;
  337. }
  338. else
  339. {
  340. m_fsm.m_strHintCallNum = "";
  341. }
  342. //DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("recv call num = %s",m_fsm.m_strHintCallNum);
  343. m_fsm.PostEventFIFO(new FSMEvent(USER_EVT_PICKUP_CALL));
  344. }
  345. break;
  346. case EVENT_MOD_CONNECT_HANDFREE_TO_PICKUP: // 免提->提机
  347. {
  348. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("免提->提机");
  349. m_fsm.PostEventFIFO(new FSMEvent(USER_EVT_TO_PICKUP));
  350. if (strcmp(m_fsm.GetCurrStateName(),"HandFree")==0){
  351. m_fsm.m_bAgentHandFree = false;
  352. }
  353. SendCurAudioDevice();
  354. }
  355. break;
  356. case EVENT_MOD_CONNECT_PICKUP_TO_HANDFREE: // 提机->免提
  357. {
  358. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("提机->免提");
  359. m_fsm.PostEventFIFO(new FSMEvent(USER_EVT_TO_HANDFREE));
  360. if (strcmp(m_fsm.GetCurrStateName(),"Pickup")==0){
  361. m_fsm.m_bAgentHandFree = true;
  362. }
  363. SendCurAudioDevice();
  364. }
  365. break;
  366. case EVENT_MOD_CONNECT_AGENT_HANDFREE_PICKUP: // 坐席控制免提->提机
  367. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("免提->提机");
  368. m_fsm.PostEventFIFO(new FSMEvent(USER_EVT_TO_PICKUP));
  369. SendCurAudioDevice();
  370. break;
  371. case EVENT_MOD_CONNECT_AGENT_PICKUP_HANDFREE: // 坐席控制提机->免提
  372. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("提机->免提");
  373. m_fsm.PostEventFIFO(new FSMEvent(USER_EVT_TO_HANDFREE));
  374. SendCurAudioDevice();
  375. break;
  376. case EVENT_MOD_CONNECT_BEGAIN_RECORD_CALL:
  377. {
  378. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("开始远程双录呼叫.");
  379. m_fsm.m_bNeedQueueName = true;
  380. m_fsm.PostEventFIFO(new FSMEvent(USER_EVT_DOUBLE_RECORD_CALL));
  381. if (m_fsm.m_bHandFree){
  382. LogEvent(Severity_Middle,LOG_EVT_HANDFREE_MODE_REMOTE_CALL,"remote double call start with hand free mode.");
  383. }
  384. else{
  385. LogEvent(Severity_Middle,LOG_EVT_PICKUP_MODE_REMOTE_CALL,"remote double call start with pick up mode.");
  386. }
  387. }
  388. break;
  389. case EVENT_MOD_CONNECT_STOP_RECORD_BROADCAST:
  390. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("双录播报完结束,重置电话状态");
  391. m_fsm.PostEventFIFO(new FSMEvent(USER_EVT_STOP_RECORD_BROADCAST));
  392. break;
  393. case EVENT_MOD_CONNECT_HANGUP: // 挂机
  394. {
  395. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("断开呼叫");
  396. m_fsm.PostEventFIFO(new FSMEvent(USER_EVT_HANGUP));
  397. m_fsm.m_bHangup=true;
  398. }
  399. break;
  400. case EVENT_MOD_CONNECT_HANGUP_BY_CONNECTING: // 话筒未接通时挂机
  401. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("话筒未接通时断开呼叫");
  402. m_fsm.PostEventFIFO(new FSMEvent(USER_EVT_HANGUP));
  403. //m_fsm.m_bHandFree = TRUE;
  404. m_fsm.m_bHangup=true;
  405. break;
  406. case EVENT_MOD_CONNECT_HANGUP_BY_AGENT: // 授权操作
  407. m_fsm.PostEventFIFO(new FSMEvent(USER_EVT_AGENT_WRITABLE));
  408. case LOG_EVT_MOD_ASSISCHAN_STARTED_SUCCESS:
  409. Sleep(500);
  410. m_fsm.PostEventFIFO(new FSMEvent(USER_EVT_ASSISTCHAN_IDEL));
  411. m_fsm.m_bConAssist = false;
  412. GetFunction()->SetTimer(2, this, 3900);
  413. if(NULL != m_pCounterConnectorChannel){
  414. m_bConnectAssist = false;
  415. m_pCounterConnectorChannel->GetFunction()->CloseSession();
  416. #ifdef RVC_OS_WIN
  417. m_pCounterConnectorChannel->SafeDelete();
  418. #endif
  419. m_pCounterConnectorChannel = NULL;
  420. //DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Close AssistChannel Session.");
  421. }
  422. if(NULL == m_pCounterConnectorChannel){
  423. if (Error_Succeed == ConnectAssistChannel()){
  424. m_bConnectAssist = true;
  425. }
  426. else{
  427. m_bConnectAssist = false;
  428. GetFunction()->SetTimer(1, this, 3600);
  429. }
  430. }
  431. break;
  432. case LOG_EVT_MOD_SIPPHONE_STARTED_SUCCESS:
  433. //DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("recv LOG_EVT_MOD_SIPPHONE_STARTED_SUCCESS");
  434. Sleep(890);
  435. m_fsm.PostEventFIFO(new FSMEvent(USER_EVT_SIPPHONE_IDEL));
  436. m_fsm.m_bConSipphone = false;
  437. GetFunction()->SetTimer(3, this, 3700);
  438. break;
  439. case LOG_EVT_UI_STARTREMOTERECORD:
  440. {
  441. //DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("start sales remote record video,get pos = %s",pszMessage);
  442. Handle_StartRemoteRecord(pszMessage);
  443. }
  444. break;
  445. case LOG_EVT_UI_STOPREMOTERECORD:
  446. //DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("begin stop double record video,and cur state name is %s.",m_fsm.GetCurrStateName());
  447. m_fsm.PostEventFIFO(new FSMEvent(USER_EVT_STOPLOACALREMOTEVIDEO));
  448. m_bIsRemoteRecord = false;
  449. break;
  450. case LOG_EVT_UI_RETURNMENU:
  451. if (m_bIsSalesRecord)
  452. {
  453. //DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("stop sales record video by return menu");
  454. m_fsm.PostEventFIFO(new FSMEvent(USER_EVT_STOPLOCALVIDEO));
  455. m_bIsSalesRecord = false;
  456. }
  457. if (m_bIsRemoteRecord)
  458. {
  459. //DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("stop remote record video by return menu.");
  460. if (m_fsm.m_CallingParam.nCallType != DOUBLERECORD_CALLTYPE){
  461. m_fsm.PostEventFIFO(new FSMEvent(USER_EVT_STOPLOACALREMOTEVIDEO));
  462. }
  463. else{
  464. //DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("hangup call by return menu, CurrStateName is %s.", m_fsm.GetCurrStateName());
  465. m_fsm.PostEventFIFO(new FSMEvent(USER_EVT_HANGUP));
  466. m_fsm.m_bHangup=true;
  467. }
  468. m_bIsRemoteRecord = false;
  469. }
  470. break;
  471. case LOG_EVT_UI_STARTPHOTOGRAPH:
  472. if (_stricmp(m_fsm.GetCurrStateName(),"Offline")!=0){
  473. LogEvent(Severity_Middle,EVENT_MOD_CONNECT_HANGUP,"UI start photograph, hangup!");
  474. }
  475. //else{
  476. // DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("offline state,ignore UI_STARTPHOTOGRAPH hangup event");
  477. //}
  478. break;
  479. case EVENT_MOD_SIP_GET_VIDEO_FAILED:
  480. HandleGetVideoFailedEvent();
  481. break;
  482. default:
  483. break;
  484. }
  485. }
  486. CServerSessionBase*CCounterConnectorEntity::OnNewSession(const char* /*pszRemoteEntityName*/, const char* /*pszClass*/)
  487. {
  488. m_pCurrentSession = new CCounterConnectorSession(this);
  489. return m_pCurrentSession;
  490. }
  491. bool CCounterConnectorEntity ::IsService() const
  492. {
  493. return true;
  494. }
  495. void CCounterConnectorEntity::OnTimeout(DWORD dwTimerID)
  496. {
  497. if (1 == dwTimerID){
  498. if (false == m_bConnectAssist) {
  499. if (Error_Succeed == ConnectAssistChannel()) {
  500. m_bConnectAssist = true;
  501. }
  502. }
  503. if (m_bConnectAssist) {
  504. GetFunction()->KillTimer(1);
  505. }
  506. }
  507. else if(2 == dwTimerID) {
  508. if (false == m_fsm.m_bConAssist) {
  509. if (m_fsm.ReConnectionAssistchan()) {
  510. m_fsm.m_bConAssist = true;
  511. }
  512. }
  513. if (true == m_fsm.m_bConAssist) {
  514. GetFunction()->KillTimer(2);
  515. }
  516. }
  517. else if (3 == dwTimerID) {
  518. if (false == m_fsm.m_bConSipphone) {
  519. if (m_fsm.ReConnectionSipphone(false)) {
  520. m_fsm.m_bConSipphone = true;
  521. }
  522. else {
  523. m_iConSipphoneFaileTimes++;
  524. GetFunction()->ResetTimer(3, m_iConSipphoneFaileTimes*3000);
  525. }
  526. }
  527. if (m_fsm.m_bConSipphone || m_iConSipphoneFaileTimes >= 5) {
  528. GetFunction()->KillTimer(3);
  529. }
  530. }
  531. }
  532. //change audio device message
  533. void CCounterConnectorEntity ::OnReceivePkt(int type, int sub_type, const char *buffer, int size)
  534. {
  535. //DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("recv pkt type=%d,subtype=%d",type,sub_type);
  536. if (type == ACM_TYPE_DEVICE)
  537. {
  538. switch (sub_type)
  539. {
  540. //设备切换
  541. //change to handfree
  542. case ACM_CHANGE_HANDFREE:
  543. DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("recv change audiodevice to handfree");
  544. if (!m_fsm.m_bAgentHandFree)
  545. {
  546. LogEvent(Severity_Middle,EVENT_MOD_CONNECT_AGENT_PICKUP_HANDFREE,"agent change audio device to handfree");
  547. m_fsm.m_bAgentHandFree = true;
  548. }
  549. else
  550. {
  551. DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("agent want change audiodevice to handfree,but the device is handfree now");
  552. }
  553. break;
  554. //change to pickup
  555. case ACM_CHANGE_PICKUP:
  556. DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("recv change audio device to pickup");
  557. if (m_fsm.m_bAgentHandFree)
  558. {
  559. LogEvent(Severity_Middle,EVENT_MOD_CONNECT_AGENT_HANDFREE_PICKUP,"agent change audio device to pickup");
  560. m_fsm.m_bAgentHandFree = false;
  561. }
  562. else
  563. {
  564. DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("agent want change audio device to pickup,but the device is pickup now");
  565. }
  566. break;
  567. default:
  568. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("unknown sub_type %d from agent!", sub_type);
  569. break;
  570. }
  571. }
  572. else if (type == ACM_TYPE_CALLTRANS)
  573. {
  574. //DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("recv ACM_TYPE_CALLTRANS");
  575. if (sub_type == ACM_CALLTRANS_NUM)
  576. {
  577. //CALL transfer
  578. CallTransferInfo Callnum;
  579. SpBuffer buf;
  580. buf.OpenRead(buffer,size);
  581. Callnum.Serialize(buf);
  582. //DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("recv ACM_CALLTRANS_NUM = %s",Callnum.CallNum);
  583. //广播,业务中台接收
  584. SpSendBroadcast(GetFunction(), SP_MSG_OF(CallTransferInfo), SP_MSG_SIG_OF(CallTransferInfo), Callnum);
  585. }
  586. }
  587. else if (type == ACM_TYPE_AGENTVIDEOTYPE)
  588. {
  589. if (sub_type == ACM_AGENTVIDEOTYPE_ONEWAY)
  590. {
  591. //广播单向视频
  592. AgentVideoType agentvideotype;
  593. agentvideotype.VideoType = 0;
  594. //DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("Broadcast Oneway video");
  595. SpSendBroadcast(GetFunction(), SP_MSG_OF(AgentVideoType), SP_MSG_SIG_OF(AgentVideoType), agentvideotype);
  596. }
  597. else if (sub_type == ACM_AGENTVIDEOTYPE_TWOWAY)
  598. {
  599. //广播双向视频
  600. AgentVideoType agentvideotype;
  601. agentvideotype.VideoType = 1;
  602. //DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("Broadcast Twoway Video");
  603. SpSendBroadcast(GetFunction(), SP_MSG_OF(AgentVideoType), SP_MSG_SIG_OF(AgentVideoType), agentvideotype);
  604. }
  605. }
  606. }
  607. CSimpleStringA CCounterConnectorEntity ::BuildVideoDesc(int local_view_x, int local_view_y, int local_view_cx, int local_view_cy)
  608. {
  609. char param[512] = {0};
  610. snprintf(param, 512,
  611. "remote_ip:0\r\n"
  612. "remote_video_rtp:0\r\n"
  613. "remote_video_width:0\r\n"
  614. "remote_video_height:0\r\n"
  615. "remote_video_fps:0\r\n"
  616. "local_view_x:%d\r\n"
  617. "local_view_y:%d\r\n"
  618. "local_view_cx:%d\r\n"
  619. "local_view_cy:%d\r\n"
  620. "remote_view_x:0\r\n"
  621. "remote_view_y:0\r\n"
  622. "remote_view_cx:0\r\n"
  623. "remote_view_cy:0\r\n\r\n",
  624. local_view_x, local_view_y, local_view_cx, local_view_cy);
  625. return CSimpleStringA(param);
  626. }
  627. CSimpleStringA CCounterConnectorEntity ::BuildDoubleVideoDesc(int local_view_x, int local_view_y, int local_view_cx, int local_view_cy, int remote_view_x, int remote_view_y, int remote_view_cx, int remote_view_cy)
  628. {
  629. char param[512] = {0};
  630. snprintf(param, 512,
  631. "remote_ip:0\r\n"
  632. "remote_video_rtp:0\r\n"
  633. "remote_video_width:0\r\n"
  634. "remote_video_height:0\r\n"
  635. "remote_video_fps:0\r\n"
  636. "local_view_x:%d\r\n"
  637. "local_view_y:%d\r\n"
  638. "local_view_cx:%d\r\n"
  639. "local_view_cy:%d\r\n"
  640. "remote_view_x:%d\r\n"
  641. "remote_view_y:%d\r\n"
  642. "remote_view_cx:%d\r\n"
  643. "remote_view_cy:%d\r\n\r\n",
  644. local_view_x, local_view_y, local_view_cx, local_view_cy,
  645. remote_view_x, remote_view_y, remote_view_cx, remote_view_cy);
  646. return CSimpleStringA(param);
  647. }
  648. CSimpleStringA CCounterConnectorEntity ::ConstructVideoParam(CSimpleStringA strMsg, bool bDoubleVideo)
  649. {
  650. int lxPos,lyPos,lwidth,lheight;
  651. CSimpleStringA strVideoParam;
  652. char str[256] = {0};
  653. if (false == bDoubleVideo){
  654. sscanf(strMsg.GetData(), "%d@%d@%d@%d@%d@%s", &lxPos, &lyPos, &lwidth, &lheight, str);
  655. DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("local video param : (x=%d,y=%d,width=%d,height=%d).",lxPos,lyPos,lwidth,lheight);
  656. strVideoParam = BuildVideoDesc(lxPos,lyPos,lwidth,lheight);
  657. }
  658. else{
  659. int iPostionArr[4][2] = {0};
  660. if (strMsg.GetLength() >0)
  661. {
  662. CAutoArray<CSimpleStringA> arrstr = strMsg.Split('@');
  663. if (arrstr.GetCount() >= 4)
  664. {
  665. for(int i=0; i<4; i++)
  666. {
  667. sscanf(arrstr[i].GetData(), "%d|%d", &iPostionArr[i][0], &iPostionArr[i][1]);
  668. }
  669. }
  670. }
  671. //DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("remote record local video param : (x=%d,y=%d,width=%d,height=%d), remote video param : (x=%d,y=%d,width=%d,height=%d)",
  672. // iPostionArr[0][0], iPostionArr[1][0],iPostionArr[2][0], iPostionArr[3][0],iPostionArr[0][1], iPostionArr[1][1],iPostionArr[2][1], iPostionArr[3][1]);
  673. strVideoParam = BuildDoubleVideoDesc(iPostionArr[0][0], iPostionArr[1][0],iPostionArr[2][0], iPostionArr[3][0],iPostionArr[0][1], iPostionArr[1][1],iPostionArr[2][1], iPostionArr[3][1]);
  674. }
  675. return strVideoParam;
  676. }
  677. void CCounterConnectorEntity::Handle_StartRemoteRecord(const char* pszMessage)
  678. {
  679. CSimpleStringA strMsg = pszMessage;
  680. #ifdef RVC_OS_WIN
  681. CSimpleStringA strVideo = ConstructVideoParam(strMsg, true);
  682. #else
  683. CSimpleStringA strVideo = ConstructVideoRenderParam(strMsg, true);
  684. #endif
  685. m_fsm.PostEventFIFO(new ShowLocalAndRemoteVideoEvent(strVideo)); // 连坐席双录
  686. m_bIsRemoteRecord = true;
  687. m_bIsRemoteRecordStopSpeakerCapture = false;
  688. }
  689. //send cur audio device to agent
  690. void CCounterConnectorEntity ::SendCurAudioDevice()
  691. {
  692. ChannelService_Send_Info Info;
  693. Info.compress = false;
  694. Info.encrypt = false;
  695. Info.type = ACM_TYPE_DEVICE;
  696. Info.id = 0;
  697. Info.sub_type = ACM_AUDIO_DEVICE;
  698. Info.data.Alloc(sizeof(int));
  699. SpBuffer buf;
  700. buf.OpenWrite();
  701. int nDevice = 0;
  702. if (m_fsm.m_bIsAgentControl)
  703. {
  704. if (m_fsm.m_bAgentHandFree)
  705. {
  706. nDevice = 0;
  707. }
  708. else
  709. {
  710. nDevice = 1;
  711. }
  712. }
  713. else
  714. {
  715. if (m_fsm.m_bHandFree)
  716. {
  717. nDevice = 0;
  718. }
  719. else
  720. {
  721. nDevice = 1;
  722. }
  723. }
  724. CSmartPointer<IEntityFunction> Func = GetFunction();
  725. CSimpleStringA strValue("");
  726. Func->GetSysVar(SYSVAR_SOUNDCARDSTATE, strValue);
  727. if ('N' != strValue[0]) {
  728. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Sound Card State %s.", strValue.GetData());
  729. }
  730. if ('H' == strValue[0]) {
  731. nDevice = 1;
  732. if (m_fsm.m_bIsAgentControl){
  733. m_fsm.m_bAgentHandFree = false;
  734. }
  735. }
  736. else if('P' == strValue[0]){
  737. nDevice = 0;
  738. if (m_fsm.m_bIsAgentControl) {
  739. m_fsm.m_bAgentHandFree = true;
  740. }
  741. }
  742. buf & nDevice;
  743. Info.data = buf.ToBlob();
  744. m_pCounterConnectorChannel->Send(Info);
  745. //DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("send cur Audio device = %d",nDevice);
  746. }
  747. void CCounterConnectorEntity::SetCallType(CallingTypeEnum eType)
  748. {
  749. m_fsm.SetCallingType(eType);
  750. }
  751. DeviceTypeEnum CCounterConnectorEntity::RvcGetDeviceType()
  752. {
  753. DeviceTypeEnum eType = eStand2sType;
  754. CSmartPointer<IEntityFunction> spFunction = GetFunction();
  755. CSystemStaticInfo stStaticinfo;
  756. spFunction->GetSystemStaticInfo(stStaticinfo);
  757. if (_stricmp(stStaticinfo.strMachineType, "RVC.Stand1SPlus") == 0) {
  758. eType = eStand1SPlusType;
  759. }
  760. else if (_stricmp(stStaticinfo.strMachineType, "RVC.CardStore") == 0 || _stricmp(stStaticinfo.strMachineType, "RVC.CardPrinter") == 0) {
  761. eType = eCardStore;
  762. }
  763. else {
  764. eType = eStand2sType;
  765. }
  766. if (eType >= 0 && eType < sizeof(Device_Type_Table) / sizeof(char*)) {
  767. DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("device type is %s.", Device_Type_Table[eType]);
  768. }
  769. return eType;
  770. }
  771. ChannelCounterConnectorClient::ChannelCounterConnectorClient( CCounterConnectorEntity *pEntity ) : ChannelService_ClientBase(pEntity)
  772. {
  773. m_eLastState = eChannelState_Idle;
  774. }
  775. void ChannelCounterConnectorClient::OnMessage(ErrorCodeEnum Error, ChannelService_State_Info &Msg, CSmartPointer<IReleasable> pData)
  776. {
  777. if (Error == Error_Succeed)
  778. {
  779. CCounterConnectorEntity *pEntity = static_cast<CCounterConnectorEntity*>(m_pEntityBase);
  780. if (Msg.state == eChannelState_Idle)
  781. {
  782. pEntity->m_fsm.m_bIsAgentControl = false;
  783. if (eChannelState_Connecting == m_eLastState){
  784. LogWarn(Severity_Low, Error_Debug, LOG_WARN_COUNTERCONNECT_ASSIST_CONNECT_FAILED,"make call failed for assistant channel connect failed!");
  785. }
  786. }
  787. else if (Msg.state == eChannelState_Connected)
  788. {
  789. pEntity->m_fsm.m_bIsAgentControl = true;
  790. pEntity->SendCurAudioDevice();
  791. }
  792. else if (eChannelState_Connecting == Msg.state){
  793. }
  794. else if(eChannelState_Closing == Msg.state){
  795. if (eChannelState_Connecting == m_eLastState){
  796. LogWarn(Severity_Low, Error_Debug, LOG_WARN_COUNTERCONNECT_ASSIST_CONNECT_FAILED,"make call failed for assistant channel closed.");
  797. }
  798. }
  799. m_eLastState = Msg.state;
  800. }
  801. }
  802. void ChannelCounterConnectorClient::OnMessage( ErrorCodeEnum Error, ChannelService_Packet_Info &Msg, CSmartPointer<IReleasable> pData )
  803. {
  804. if (Error == Error_Succeed) {
  805. CCounterConnectorEntity *pEntity = static_cast<CCounterConnectorEntity*>(m_pEntityBase);
  806. pEntity->OnReceivePkt(Msg.type, Msg.sub_type, (const char*)Msg.data.m_pData, Msg.data.m_iLength);
  807. }
  808. }
  809. void CCounterConnectorSession::Handle_StartCall(SpReqAnsContext<ConnectService_StartCall_Req, ConnectService_StartCall_Ans>::Pointer ctx)
  810. {
  811. DbgToBeidou(ctx->link, __FUNCTION__)();
  812. ErrorCodeEnum rc = Error_Succeed;
  813. m_pEntity->m_fsm.m_CallingParam.connect_ip = ctx->Req.connect_ip;
  814. m_pEntity->m_fsm.m_CallingParam.connect_port = ctx->Req.connect_port;
  815. m_pEntity->m_fsm.m_CallingParam.nCallType = (CallingTypeEnum)ctx->Req.callingtype;
  816. m_pEntity->m_fsm.m_CallingParam.connect_session = ctx->Req.connect_session;
  817. m_pEntity->m_fsm.m_CallingParam.assistant_port = ctx->Req.assistant_port;
  818. m_pEntity->m_fsm.m_CallingParam.subid = ctx->Req.subid;
  819. m_pEntity->m_fsm.m_bNeedQueueName = true;
  820. ctx->Answer((ErrorCodeEnum)rc);
  821. }
  822. void CCounterConnectorSession::Handle_StartCallExternal(SpReqAnsContext<ConnectService_StartCallExternal_Req, ConnectService_StartCallExternal_Ans>::Pointer ctx)
  823. {
  824. DbgToBeidou(ctx->link, __FUNCTION__)();
  825. ErrorCodeEnum rc = Error_Succeed;
  826. ctx->Answer((ErrorCodeEnum)rc);
  827. }
  828. void CCounterConnectorSession::Handle_StopCall(SpReqAnsContext<ConnectService_StopCall_Req, ConnectService_StopCall_Ans>::Pointer ctx)
  829. {
  830. DbgToBeidou(ctx->link, __FUNCTION__)();
  831. ErrorCodeEnum rc = Error_Succeed;
  832. m_pEntity->m_fsm.PostEventFIFO(new FSMEvent(USER_EVT_HANGUP));
  833. ctx->Answer((ErrorCodeEnum)rc);
  834. }
  835. void CCounterConnectorSession::Handle_GetCallRouteType(SpReqAnsContext<ConnectService_GetCallRouteType_Req, ConnectService_GetCallRouteType_Ans>::Pointer ctx)
  836. {
  837. DbgToBeidou(ctx->link, __FUNCTION__)();
  838. ctx->Ans.RouteType = m_pEntity->m_iRouteType;
  839. ctx->Answer(Error_Succeed);
  840. }
  841. void CCounterConnectorSession::Handle_SetVideoCallRouteParams(SpReqAnsContext<ConnectService_SetVideoCallRouteParams_Req, ConnectService_SetVideoCallRouteParams_Ans>::Pointer ctx)
  842. {
  843. DbgToBeidou(ctx->link, __FUNCTION__)();
  844. if (m_pEntity->m_iRouteType) {
  845. m_pEntity->SetCallRouteParams(ctx->Req.BusinessName, ctx->Req.CallPriority);
  846. ctx->Ans.ErrorCode = Error_Succeed;
  847. ctx->Ans.ErrorMsg = CSimpleStringA2W("设置呼叫路由参数成功.");
  848. }
  849. else {
  850. ctx->Ans.ErrorCode = Error_Param;
  851. ctx->Ans.ErrorMsg = CSimpleStringA2W("该设备不支持新模式呼叫路由.");
  852. }
  853. ctx->Answer(Error_Succeed);
  854. }
  855. void CCounterConnectorSession::Handle_GetPickUpStatus(SpReqAnsContext<ConnectService_GetPickUpStatus_Req, ConnectService_GetPickUpStatus_Ans>::Pointer ctx)
  856. {
  857. DbgToBeidou(ctx->link, __FUNCTION__)();
  858. if (m_pEntity->m_fsm.m_bHandFree) {
  859. ctx->Ans.iStatus = 0;
  860. }
  861. else {
  862. ctx->Ans.iStatus = 1;
  863. }
  864. ctx->Answer(Error_Succeed);
  865. }
  866. void CCounterConnectorSession::OnClose(ErrorCodeEnum eErrorCode )
  867. {
  868. }
  869. SP_BEGIN_ENTITY_MAP()
  870. SP_ENTITY(CCounterConnectorEntity)
  871. SP_END_ENTITY_MAP()