mod_assistantchannel.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574
  1. #include "stdafx.h"
  2. #include "mod_assistantchannel.h"
  3. #include "EventCode.h"
  4. static const char *__states[] = {
  5. "Idle", "Connecting", "Connected", "Closing"
  6. };
  7. inline const char *state2str(int state)
  8. {
  9. return __states[state];
  10. }
  11. static __inline unsigned int hash32_buf(const void *bf, size_t len, unsigned int hash)
  12. {
  13. const unsigned char *s = (const unsigned char*)bf;
  14. while (len-- != 0) /* "nemesi": k=257, r=r*257 */
  15. hash = hash * 257 + *s++;
  16. return (hash * 257);
  17. }
  18. static int MakeDesc(DWORD eScreen,DeviceTypeEnum eDevicetype)
  19. {
  20. if (eScreen == 1)
  21. {
  22. if (eMobilePadType == eDevicetype)
  23. {
  24. return media_desc_encode(
  25. ACM_VIDEO_MODE_SQUARE, ACM_VIDEO_ENCODE_H264, ACM_VIDEO_FPS_MOBILE,
  26. ACM_VIDEO_MODE_QVGA, ACM_VIDEO_ENCODE_H264, ACM_VIDEO_FPS_MOBILEAGENT);
  27. }
  28. else if((ePadtype == eDevicetype)||(eDesk2SType == eDevicetype)||(eDesk1SType == eDevicetype)||(eDesk2SIntegratedType == eDevicetype))
  29. {
  30. return media_desc_encode(
  31. ACM_VIDEO_MODE_SQUARE, ACM_VIDEO_ENCODE_H264, ACM_VIDEO_FPS_MOBILE,
  32. ACM_VIDEO_MODE_QVGA, ACM_VIDEO_ENCODE_H264, ACM_VIDEO_FPS_MOBILE);
  33. }
  34. else
  35. {
  36. return media_desc_encode(
  37. ACM_VIDEO_MODE_SQUARE, ACM_VIDEO_ENCODE_H264, ACM_VIDEO_FPS_BASELINE,
  38. ACM_VIDEO_MODE_QVGA, ACM_VIDEO_ENCODE_H264, ACM_VIDEO_FPS_BASELINE);
  39. }
  40. }
  41. else if (eScreen == 2)
  42. {
  43. return media_desc_encode(
  44. ACM_VIDEO_MODE_SQUARE, ACM_VIDEO_ENCODE_H264, ACM_VIDEO_FPS_BASELINE,
  45. ACM_VIDEO_MODE_VGA, ACM_VIDEO_ENCODE_H264, ACM_VIDEO_FPS_BASELINE);
  46. }
  47. else
  48. {
  49. assert(0);
  50. }
  51. return 0;
  52. }
  53. static void __on_recv_pkt(bizchan_t *chan, int type, int sub_type, int id, const char *pkt, int pkt_size, void *user_data)
  54. {
  55. CBizChannelEntity *pThis = static_cast<CBizChannelEntity *>(user_data);
  56. pThis->_on_recv_pkt(type, sub_type, id, pkt, pkt_size);
  57. }
  58. static void __on_connect(bizchan_t *chan, int error, const char *remote_ip, int remote_video_rtp, int remote_video_desc, const char *remote_client_id, void *user_data)
  59. {
  60. CBizChannelEntity *pThis = static_cast<CBizChannelEntity *>(user_data);
  61. pThis->_on_connect(error, remote_ip, remote_video_rtp, remote_video_desc);
  62. }
  63. static void __on_close(bizchan_t *chan, void *user_data)
  64. {
  65. CBizChannelEntity *pThis = static_cast<CBizChannelEntity *>(user_data);
  66. pThis->_on_close();
  67. }
  68. static void __on_destroy(bizchan_t *chan, void *user_data)
  69. {
  70. }
  71. static void __dbg(void *user_data, const char *fmt, va_list arg)
  72. {
  73. //vDbg(fmt, arg);
  74. #if defined(RVC_OS_WIN)
  75. int n = _vscprintf(fmt, arg);
  76. #else
  77. int n = _scprintf(fmt, arg);
  78. #endif //RVC_OS_WIN
  79. if (n >= MAX_PATH) {
  80. char* buf = (char*)malloc((size_t)(n + 1));
  81. vsnprintf(buf, n + 1, fmt, arg);
  82. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("%s", buf);
  83. free(buf);
  84. }
  85. else {
  86. char strlog[MAX_PATH] = { 0 };
  87. #if defined(RVC_OS_WIN)
  88. _vsnprintf(strlog, MAX_PATH, fmt, arg);
  89. #else
  90. vsnprintf(strlog, MAX_PATH, fmt, arg);
  91. #endif //RVC_OS_WIN
  92. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("%s", strlog);
  93. }
  94. }
  95. void CBizChannelEntity::OnPreStart(CAutoArray<CSimpleStringA> strArgs,CSmartPointer<ITransactionContext> pTransactionContext)
  96. {
  97. ErrorCodeEnum Error = __OnStart(Error_Succeed);
  98. pTransactionContext->SendAnswer(Error);
  99. }
  100. void CBizChannelEntity::OnPreClose(EntityCloseCauseEnum eCloseCause,CSmartPointer<ITransactionContext> pTransactionContext)
  101. {
  102. ErrorCodeEnum Error = __OnClose(Error_Succeed);
  103. pTransactionContext->SendAnswer(Error);
  104. }
  105. ErrorCodeEnum CBizChannelEntity::__OnStart(ErrorCodeEnum preOperationError)
  106. {
  107. //MessageBoxA(0,0,0,0);
  108. bizchan_lib_init();
  109. m_eState = eChannelState_Idle;
  110. m_pChan = NULL;
  111. m_eDeviceType = RvcGetDeviceType();
  112. ListEntry_InitHead(&m_stateList);
  113. ListEntry_InitHead(&m_rxpktList);
  114. return Error_Succeed;
  115. }
  116. void CBizChannelEntity::OnStarted()
  117. {
  118. LogEvent(Severity_Middle, LOG_EVT_MOD_ASSISCHAN_STARTED_SUCCESS, "assistant channel started successfully.");
  119. }
  120. DeviceTypeEnum CBizChannelEntity::RvcGetDeviceType()
  121. {
  122. DeviceTypeEnum eType = eStand2sType;
  123. CSmartPointer<IEntityFunction> spFunction = GetFunction();
  124. CSystemStaticInfo stStaticinfo;
  125. spFunction->GetSystemStaticInfo(stStaticinfo);
  126. if (_stricmp(stStaticinfo.strMachineType, "RVC.Stand1SPlus") == 0) {
  127. eType = eStand1SPlusType;
  128. }
  129. else if (_stricmp(stStaticinfo.strMachineType,"RVC.PAD")==0){
  130. if (_stricmp(stStaticinfo.strSite,"CMB.FLB")==0){
  131. eType = eMobilePadType;
  132. }
  133. else{
  134. eType = ePadtype;
  135. }
  136. }
  137. else if (_stricmp(stStaticinfo.strMachineType,"RPM.Stand1S")==0){
  138. eType = eRpm1sType;
  139. }
  140. else if (_stricmp(stStaticinfo.strMachineType,"RVC.Desk1S")==0){
  141. eType = eDesk1SType;
  142. }
  143. else if (stricmp(stStaticinfo.strMachineType, "RVC.CardStore") == 0 || stricmp(stStaticinfo.strMachineType, "RVC.CardPrinter") == 0) {
  144. eType = eCardStore;
  145. }
  146. else{
  147. eType = eStand2sType;
  148. }
  149. if (eType >= 0 && eType < sizeof(Device_Type_Table)/sizeof(char*)){
  150. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("device type is %s.", Device_Type_Table[eType]);
  151. }
  152. return eType;
  153. }
  154. ErrorCodeEnum CBizChannelEntity::__OnClose(ErrorCodeEnum preOperationError)
  155. {
  156. //.....
  157. bizchan_lib_term();
  158. return Error_Succeed;
  159. }
  160. CServerSessionBase* CBizChannelEntity::OnNewSession(const char* pszRemoteEntityName, const char * pszClass)
  161. {
  162. return new ChannelServiceSession(this, m_id_seq++);
  163. }
  164. ErrorCodeEnum CBizChannelEntity::Connect(const char *ip, int port, const char *callno, CallingTypeEnum eType)
  165. {
  166. ErrorCodeEnum Error = Error_Succeed;
  167. if (m_eState == eChannelState_Idle)
  168. {
  169. CSystemStaticInfo Info;
  170. bizchan_config_t config = {0};
  171. bizchan_callback_t cb = {0};
  172. GetFunction()->GetSystemStaticInfo(Info);
  173. config.proxy_server = const_cast<char*>(ip);
  174. config.proxy_server_port = port;
  175. config.session_id = const_cast<char*>(((const char*)Info.strTerminalID));
  176. config.call_no = const_cast<char*>(callno);
  177. config.client_id = "";
  178. config.video.desc = MakeDesc(Info.eScreen,m_eDeviceType);
  179. config.video.rtp_port = REC_COMMON_VIDEO_PORT;
  180. cb.user_data = this;
  181. cb.on_close = &__on_close;
  182. cb.on_connect = &__on_connect;
  183. cb.on_destroy = &__on_destroy;
  184. cb.on_recv_pkt = &__on_recv_pkt;
  185. cb.dbg = &__dbg;
  186. int rc = bizchan_create(&config, &cb, &m_pChan);
  187. if (rc == 0) {
  188. rc = bizchan_start_connect(m_pChan);
  189. }
  190. if (rc != 0) {
  191. Error = Error_Unexpect;
  192. }
  193. else {
  194. ChangeState(eChannelState_Connecting);
  195. }
  196. }
  197. else
  198. {
  199. Error = Error_InvalidState;
  200. }
  201. return Error;
  202. }
  203. ErrorCodeEnum CBizChannelEntity::Close()
  204. {
  205. ErrorCodeEnum Error = Error_Succeed;
  206. if (m_eState == eChannelState_Connecting || m_eState == eChannelState_Connected) {
  207. int rc = bizchan_start_close(m_pChan);
  208. if (rc == 0) {
  209. ChangeState(eChannelState_Closing);
  210. } else {
  211. Error = Error_Unexpect;
  212. }
  213. } else {
  214. Error = Error_InvalidState;
  215. }
  216. return Error_Succeed;
  217. }
  218. ErrorCodeEnum CBizChannelEntity::RegisterState(int id, SpSubscribeContext<ChannelService_BeginState_Sub, ChannelService_State_Info>::Pointer ctx)
  219. {
  220. state_entry *pos;
  221. ListEntry_ForEach(pos, &m_stateList, state_entry, entry)
  222. {
  223. if (pos->id == id)
  224. {
  225. return Error_AlreadyExist;
  226. }
  227. }
  228. pos = new state_entry();
  229. pos->ctx = ctx;
  230. pos->id = id;
  231. ListEntry_AddTail(&m_stateList, &pos->entry);
  232. return Error_Succeed;
  233. }
  234. ErrorCodeEnum CBizChannelEntity::RegisterRxPkt(int id, SpSubscribeContext<ChannelService_BeginRecv_Sub, ChannelService_Packet_Info>::Pointer ctx)
  235. {
  236. rxpkt_entry *pos;
  237. ListEntry_ForEach(pos, &m_rxpktList, rxpkt_entry, entry)
  238. {
  239. if ((pos->id == id)&&(pos->ctx->Req.type == ctx->Req.type))
  240. {
  241. return Error_AlreadyExist;
  242. }
  243. }
  244. pos = new rxpkt_entry();
  245. pos->id = id;
  246. pos->ctx = ctx;
  247. ListEntry_AddTail(&m_rxpktList, &pos->entry);
  248. return Error_Succeed;
  249. }
  250. void CBizChannelEntity::UnregisterState(int id)
  251. {
  252. state_entry *pos,*n;
  253. ListEntry_ForEachSafe(pos,n, &m_stateList, state_entry, entry) {
  254. if (pos->id == id) {
  255. ListEntry_DeleteNode(&pos->entry);
  256. delete pos;
  257. }
  258. }
  259. }
  260. void CBizChannelEntity::UnregisterRxpkt(int id)
  261. {
  262. rxpkt_entry *pos,*n;
  263. //ListEntry_ForEach(pos, &m_rxpktList, rxpkt_entry, entry)
  264. ListEntry_ForEachSafe(pos, n, &m_rxpktList, rxpkt_entry, entry)
  265. {
  266. if((pos->id == id))
  267. {
  268. ListEntry_DeleteNode(&pos->entry);
  269. delete pos;
  270. }
  271. }
  272. }
  273. ErrorCodeEnum CBizChannelEntity::Send(int type, bool compress, bool encrypt, int sub_type, int id, CBlob &data)
  274. {
  275. if (m_eState == eChannelState_Connected) {
  276. //LOG_TRACE("tx pkt, %d bytes, type = %d, compress = %d, encrypt = %d, sub_type = %d, id = %d, hash=%d", data.m_iLength, type, !!compress, !!encrypt, sub_type, id, hash32_buf(data.m_pData, data.m_iLength, 0));
  277. //DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("tx pkt, %d bytes, type = %d, compress = %d, encrypt = %d, sub_type = %d, id = %d, hash=%d", data.m_iLength, type, !!compress, !!encrypt, sub_type, id, hash32_buf(data.m_pData, data.m_iLength, 0));
  278. int rc = bizchan_post_pkt(m_pChan, type, compress, encrypt, sub_type, id, (const char*)data.m_pData, data.m_iLength);
  279. return rc == 0 ? Error_Succeed : Error_NetBroken;
  280. }
  281. else
  282. {
  283. return Error_NetBroken;
  284. }
  285. }
  286. void CBizChannelEntity::GetIpByDomain(char* poutput, size_t ulen, const char *pinput)
  287. {
  288. #if defined(RVC_OS_WIN)
  289. bizchan_getip_bydomain(m_pChan, poutput, ulen, pinput);
  290. #endif //RVC_OS_WIN
  291. }
  292. void CBizChannelEntity::ChangeState(int new_state, const char *param)
  293. {
  294. if (m_eState != new_state) {
  295. //DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("change state from %s to %s", state2str(m_eState), state2str(new_state));
  296. m_eState = new_state;
  297. state_entry *pos;
  298. ListEntry_ForEach(pos, &m_stateList, state_entry, entry) {
  299. ChannelService_State_Info State;
  300. State.state = new_state;
  301. State.status = state2str(new_state);
  302. if (param) {
  303. State.param = param;
  304. }
  305. pos->ctx->SendMessage(State);
  306. }
  307. }
  308. }
  309. //void on_recv_pkt(int type, int sub_type, const char *pkt, int pkt_size)
  310. void CBizChannelEntity::on_recv_pkt(int type, int sub_type, int id, CBlob &data)
  311. {
  312. //LOG_TRACE("rx pkt, %d bytes, type = %d, sub_type = %d, id = %d, hash = %d", data.m_iLength, type, sub_type, id, hash32_buf(data.m_pData, data.m_iLength, 0));
  313. //DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("rx pkt, %d bytes, type = %d, sub_type = %d, id = %d, hash = %d", data.m_iLength, type, sub_type, id, hash32_buf(data.m_pData, data.m_iLength, 0));
  314. rxpkt_entry *pos;
  315. ListEntry_ForEach(pos, &m_rxpktList, rxpkt_entry, entry)
  316. {
  317. if (pos->ctx->Req.type == type)
  318. {
  319. ChannelService_Packet_Info pkt;
  320. pkt.type = type;
  321. pkt.sub_type = sub_type;
  322. pkt.id = id;
  323. //pkt.data.m_bManaged = true;
  324. pkt.data = data;
  325. //data.m_bManaged = false;
  326. pos->ctx->SendMessage(pkt);
  327. //break;
  328. }
  329. }
  330. }
  331. void CBizChannelEntity::on_connect(int error, const char *remote_ip, int remote_video_rtp, int remote_video_desc)
  332. {
  333. if (!error) {
  334. if (m_eState == eChannelState_Connecting) {
  335. CSimpleStringA strValue;
  336. ErrorCodeEnum Error = GetFunction()->GetSysVar("VideoWindowInitializeParam", strValue);
  337. if (Error == Error_Succeed) {
  338. int local_view_x;
  339. int local_view_y;
  340. int local_view_cx;
  341. int local_view_cy;
  342. int remote_view_x;
  343. int remote_view_y;
  344. int remote_view_cx;
  345. int remote_view_cy;
  346. int remote_video_width = 0;
  347. int remote_video_height = 0;
  348. {
  349. CSystemStaticInfo Info;
  350. GetFunction()->GetSystemStaticInfo(Info);
  351. if (Info.eScreen == 1)
  352. {
  353. remote_video_width = REC_COMMON_VIDEO_SSM_AGENT_WIDTH;
  354. remote_video_height = REC_COMMON_VIDEO_SSM_AGENT_HEIGHT;
  355. }
  356. else
  357. {
  358. remote_video_width = REC_COMMON_VIDEO_DSM_AGENT_WIDTH;
  359. remote_video_height = REC_COMMON_VIDEO_DSM_AGENT_HEIGHT;
  360. }
  361. }
  362. ParseVideoViewParam((LPCSTR)strValue, local_view_x, local_view_y, local_view_cx, local_view_cy,
  363. remote_view_x, remote_view_y, remote_view_cx, remote_view_cy);
  364. //DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Get Video Window Initialize Param:%d,%d,%d,%d %d,%d,%d,%d",local_view_x, local_view_y, local_view_cx, local_view_cy,
  365. //remote_view_x, remote_view_y, remote_view_cx, remote_view_cy);
  366. CSimpleStringA param;
  367. if (eMobilePadType == m_eDeviceType)
  368. {
  369. param = BuildVideoDesc(remote_ip, remote_video_rtp, remote_video_width, remote_video_height,
  370. REC_COMMON_VIDEO_FPS_MOBILE_AGENT, local_view_x, local_view_y, local_view_cx, local_view_cy,
  371. remote_view_x, remote_view_y, remote_view_cx, remote_view_cy);
  372. }
  373. else
  374. {
  375. param = BuildVideoDesc(remote_ip, remote_video_rtp, remote_video_width, remote_video_height,
  376. REC_COMMON_VIDEO_FPS, local_view_x, local_view_y, local_view_cx, local_view_cy,
  377. remote_view_x, remote_view_y, remote_view_cx, remote_view_cy);
  378. }
  379. ChangeState(eChannelState_Connected, (LPCSTR)param);
  380. }
  381. else {
  382. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("get VideoWindowInitializeParam failed!");
  383. bizchan_start_close(m_pChan);
  384. }
  385. }
  386. }
  387. else {
  388. if (m_pChan) {
  389. bizchan_close(m_pChan);
  390. bizchan_destroy(m_pChan);
  391. m_pChan = NULL;
  392. }
  393. ChangeState(eChannelState_Idle);
  394. }
  395. }
  396. void CBizChannelEntity::on_close()
  397. {
  398. if (m_pChan) {
  399. bizchan_close(m_pChan);
  400. bizchan_destroy(m_pChan);
  401. m_pChan = NULL;
  402. }
  403. ChangeState(eChannelState_Idle);
  404. }
  405. void CBizChannelEntity::_on_recv_pkt(int type, int sub_type, int id, const char *pkt, int pkt_size)
  406. {
  407. //LOG_TRACE("_on rx pkt, %d bytes, type = %d, sub_type = %d, id = %d, hash = %d", pkt_size, type, sub_type, id, hash32_buf(pkt, pkt_size, 0));
  408. NotifyOnRecvPkt *task = new NotifyOnRecvPkt();
  409. task->m_pEntity = this;
  410. task->type = type;
  411. task->sub_type = sub_type;
  412. task->id = id;
  413. task->data.m_bManaged = true;
  414. task->data.m_iLength = pkt_size;
  415. if (pkt_size)
  416. {
  417. task->data.m_pData = new char[pkt_size];
  418. memcpy(task->data.m_pData, pkt, pkt_size);
  419. } else {
  420. task->data.m_pData = NULL;
  421. }
  422. GetFunction()->PostEntityTaskFIFO(task);
  423. }
  424. void CBizChannelEntity::_on_connect(int error, const char *remote_ip, int remote_video_rtp, int remote_video_desc)
  425. {
  426. NotifyOnConnect *task = new NotifyOnConnect();
  427. task->m_pEntity = this;
  428. task->error = error;
  429. task->remote_rtp_ip = remote_ip;
  430. task->remote_video_port = remote_video_rtp;
  431. task->remote_video_desc = remote_video_desc;
  432. GetFunction()->PostEntityTaskFIFO(task);
  433. }
  434. void CBizChannelEntity::_on_close()
  435. {
  436. NotifyOnClose *task = new NotifyOnClose();
  437. task->m_pEntity = this;
  438. GetFunction()->PostEntityTaskFIFO(task);
  439. }
  440. void ChannelServiceSession::Handle_Connect( SpReqAnsContext<ChannelService_Connect_Req, ChannelService_Connect_Ans>::Pointer ctx )
  441. {
  442. DbgToBeidou(ctx->link, __FUNCTION__)();
  443. //DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("start connect, %s:%d [%s]", (LPCSTR)ctx->Req.ip, ctx->Req.port, (LPCSTR)ctx->Req.callno);
  444. ErrorCodeEnum Error = m_pEntity->Connect(ctx->Req.ip, ctx->Req.port, ctx->Req.callno, (CallingTypeEnum)ctx->Req.etype);
  445. //DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("connect Error = %d", Error);
  446. ctx->Answer(Error);
  447. }
  448. void ChannelServiceSession::Handle_Close( SpReqAnsContext<ChannelService_Close_Req, ChannelService_Close_Ans>::Pointer ctx )
  449. {
  450. DbgToBeidou(ctx->link, __FUNCTION__)();
  451. ErrorCodeEnum Error = m_pEntity->Close();
  452. ctx->Answer(Error);
  453. }
  454. void ChannelServiceSession::Handle_GetState( SpReqAnsContext<ChannelService_GetState_Req, ChannelService_GetState_Ans>::Pointer ctx )
  455. {
  456. DbgToBeidou(ctx->link, __FUNCTION__)();
  457. ctx->Ans.status = state2str(m_pEntity->GetState());
  458. ctx->Answer(Error_Succeed);
  459. }
  460. void ChannelServiceSession::Handle_BeginState( SpSubscribeContext<ChannelService_BeginState_Sub, ChannelService_State_Info>::Pointer ctx )
  461. {
  462. m_pEntity->RegisterState(m_id, ctx);
  463. }
  464. void ChannelServiceSession::Handle_EndState( SpOnewayCallContext<ChannelService_EndState_Info>::Pointer ctx )
  465. {
  466. DbgToBeidou(ctx->link, __FUNCTION__)();
  467. m_pEntity->UnregisterState(m_id);
  468. }
  469. void ChannelServiceSession::Handle_Send( SpOnewayCallContext<ChannelService_Send_Info>::Pointer ctx )
  470. {
  471. DbgToBeidou(ctx->link, __FUNCTION__)();
  472. m_pEntity->Send(ctx->Info.type, ctx->Info.compress, ctx->Info.encrypt, ctx->Info.sub_type, ctx->Info.id, ctx->Info.data);
  473. }
  474. void ChannelServiceSession::Handle_BeginRecv( SpSubscribeContext<ChannelService_BeginRecv_Sub, ChannelService_Packet_Info>::Pointer ctx )
  475. {
  476. m_pEntity->RegisterRxPkt(m_id, ctx);
  477. }
  478. void ChannelServiceSession::Handle_EndRecv( SpOnewayCallContext<ChannelService_EndRecv_Info>::Pointer ctx )
  479. {
  480. DbgToBeidou(ctx->link, __FUNCTION__)();
  481. m_pEntity->UnregisterRxpkt(m_id);
  482. }
  483. void ChannelServiceSession::Handle_GetIpByDomain(SpReqAnsContext<ChannelService_GetIpByDomain_Req, ChannelService_GetIpByDomain_Ans>::Pointer ctx)
  484. {
  485. DbgToBeidou(ctx->link, __FUNCTION__)();
  486. char strip[MAX_PATH] = {0};
  487. m_pEntity->GetIpByDomain(strip, MAX_PATH, ctx->Req.strdomain);
  488. ctx->Ans.strip = strip;
  489. ctx->Answer(Error_Succeed);
  490. }
  491. void ChannelServiceSession::OnClose( ErrorCodeEnum eErrorCode )
  492. {
  493. m_pEntity->UnregisterRxpkt(m_id);
  494. m_pEntity->UnregisterState(m_id);
  495. }
  496. SP_BEGIN_ENTITY_MAP()
  497. SP_ENTITY(CBizChannelEntity)
  498. SP_END_ENTITY_MAP()