mod_assistantchannel.cpp 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555
  1. #include "stdafx.h"
  2. #include "mod_assistantchannel.h"
  3. #include "../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))
  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. int n = _scprintf(fmt, arg);
  75. if (n >= MAX_PATH) {
  76. char* buf = (char*)malloc((size_t)(n + 1));
  77. vsnprintf(buf, n + 1, fmt, arg);
  78. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("%s", buf);
  79. free(buf);
  80. }
  81. else {
  82. char strlog[MAX_PATH] = { 0 };
  83. vsnprintf(strlog, MAX_PATH, fmt, arg);
  84. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("%s", strlog);
  85. }
  86. }
  87. void CBizChannelEntity::OnPreStart(CAutoArray<CSimpleStringA> strArgs,CSmartPointer<ITransactionContext> pTransactionContext)
  88. {
  89. ErrorCodeEnum Error = __OnStart(Error_Succeed);
  90. pTransactionContext->SendAnswer(Error);
  91. }
  92. void CBizChannelEntity::OnPreClose(EntityCloseCauseEnum eCloseCause,CSmartPointer<ITransactionContext> pTransactionContext)
  93. {
  94. ErrorCodeEnum Error = __OnClose(Error_Succeed);
  95. pTransactionContext->SendAnswer(Error);
  96. }
  97. ErrorCodeEnum CBizChannelEntity::__OnStart(ErrorCodeEnum preOperationError)
  98. {
  99. //MessageBoxA(0,0,0,0);
  100. bizchan_lib_init();
  101. m_eState = eChannelState_Idle;
  102. m_pChan = NULL;
  103. m_eDeviceType = RvcGetDeviceType();
  104. ListEntry_InitHead(&m_stateList);
  105. ListEntry_InitHead(&m_rxpktList);
  106. return Error_Succeed;
  107. }
  108. void CBizChannelEntity::OnStarted()
  109. {
  110. LogEvent(Severity_Middle, LOG_EVT_MOD_ASSISCHAN_STARTED_SUCCESS, "assistant channel started successfully.");
  111. }
  112. DeviceTypeEnum CBizChannelEntity::RvcGetDeviceType()
  113. {
  114. DeviceTypeEnum eType = eStand2sType;
  115. CSmartPointer<IEntityFunction> spFunction = GetFunction();
  116. CSystemStaticInfo stStaticinfo;
  117. spFunction->GetSystemStaticInfo(stStaticinfo);
  118. if (_stricmp(stStaticinfo.strMachineType, "RVC.Stand1SPlus") == 0) {
  119. eType = eStand1SPlusType;
  120. }
  121. else if (_stricmp(stStaticinfo.strMachineType,"RVC.PAD")==0){
  122. if (_stricmp(stStaticinfo.strSite,"CMB.FLB")==0){
  123. eType = eMobilePadType;
  124. }
  125. else{
  126. eType = ePadtype;
  127. }
  128. }
  129. else if (_stricmp(stStaticinfo.strMachineType,"RVC.Desk2S")==0){
  130. eType = eDesk2SType;
  131. WORD nMajor = stStaticinfo.MachineVersion.GetMajor();
  132. WORD nMinor = stStaticinfo.MachineVersion.GetMinor();
  133. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("MachineVersion is %d.%d", nMajor, nMinor);
  134. if (2 == nMajor){
  135. eType = eDesk2SIntegratedType;
  136. }
  137. }
  138. else if (_stricmp(stStaticinfo.strMachineType,"RPM.Stand1S")==0){
  139. eType = eRpm1sType;
  140. }
  141. else if (_stricmp(stStaticinfo.strMachineType,"RVC.Desk1S")==0){
  142. eType = eDesk1SType;
  143. }
  144. else{
  145. eType = eStand2sType;
  146. }
  147. if (eType >= 0 && eType < sizeof(Device_Type_Table)/sizeof(char*)){
  148. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("device type is %s.", Device_Type_Table[eType]);
  149. }
  150. return eType;
  151. }
  152. ErrorCodeEnum CBizChannelEntity::__OnClose(ErrorCodeEnum preOperationError)
  153. {
  154. //.....
  155. bizchan_lib_term();
  156. return Error_Succeed;
  157. }
  158. CServerSessionBase* CBizChannelEntity::OnNewSession(const char* pszRemoteEntityName, const char * pszClass)
  159. {
  160. LOG_FUNCTION();
  161. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("%s connected class = %s!", pszRemoteEntityName, pszClass);
  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. {
  189. rc = bizchan_start_connect(m_pChan);
  190. }
  191. if (rc != 0)
  192. Error = Error_Unexpect;
  193. else
  194. ChangeState(eChannelState_Connecting);
  195. }
  196. else
  197. {
  198. Error = Error_InvalidState;
  199. }
  200. return Error;
  201. }
  202. ErrorCodeEnum CBizChannelEntity::Close()
  203. {
  204. ErrorCodeEnum Error = Error_Succeed;
  205. if (m_eState == eChannelState_Connecting || m_eState == eChannelState_Connected) {
  206. int rc = bizchan_start_close(m_pChan);
  207. if (rc == 0) {
  208. ChangeState(eChannelState_Closing);
  209. } else {
  210. Error = Error_Unexpect;
  211. }
  212. } else {
  213. Error = Error_InvalidState;
  214. }
  215. return Error_Succeed;
  216. }
  217. ErrorCodeEnum CBizChannelEntity::RegisterState(int id, SpSubscribeContext<ChannelService_BeginState_Sub, ChannelService_State_Info>::Pointer ctx)
  218. {
  219. state_entry *pos;
  220. ListEntry_ForEach(pos, &m_stateList, state_entry, entry)
  221. {
  222. if (pos->id == id)
  223. {
  224. return Error_AlreadyExist;
  225. }
  226. }
  227. pos = new state_entry();
  228. pos->ctx = ctx;
  229. pos->id = id;
  230. ListEntry_AddTail(&m_stateList, &pos->entry);
  231. return Error_Succeed;
  232. }
  233. ErrorCodeEnum CBizChannelEntity::RegisterRxPkt(int id, SpSubscribeContext<ChannelService_BeginRecv_Sub, ChannelService_Packet_Info>::Pointer ctx)
  234. {
  235. rxpkt_entry *pos;
  236. ListEntry_ForEach(pos, &m_rxpktList, rxpkt_entry, entry)
  237. {
  238. if ((pos->id == id)&&(pos->ctx->Req.type == ctx->Req.type))
  239. {
  240. return Error_AlreadyExist;
  241. }
  242. }
  243. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("RegisterRxPkt id = %d",id);
  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. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("UnregisterRxpkt id = %d",pos->id);
  269. ListEntry_DeleteNode(&pos->entry);
  270. delete pos;
  271. }
  272. }
  273. }
  274. ErrorCodeEnum CBizChannelEntity::Send(int type, bool compress, bool encrypt, int sub_type, int id, CBlob &data)
  275. {
  276. if (m_eState == eChannelState_Connected) {
  277. //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));
  278. //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));
  279. int rc = bizchan_post_pkt(m_pChan, type, compress, encrypt, sub_type, id, (const char*)data.m_pData, data.m_iLength);
  280. return rc == 0 ? Error_Succeed : Error_NetBroken;
  281. }
  282. else
  283. {
  284. return Error_NetBroken;
  285. }
  286. }
  287. void CBizChannelEntity::ChangeState(int new_state, const char *param)
  288. {
  289. if (m_eState != new_state) {
  290. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("change state from %s to %s", state2str(m_eState), state2str(new_state));
  291. m_eState = new_state;
  292. state_entry *pos;
  293. ListEntry_ForEach(pos, &m_stateList, state_entry, entry) {
  294. ChannelService_State_Info State;
  295. State.state = new_state;
  296. State.status = state2str(new_state);
  297. if (param) {
  298. State.param = param;
  299. }
  300. pos->ctx->SendMessage(State);
  301. }
  302. }
  303. }
  304. void CBizChannelEntity::on_recv_pkt(int type, int sub_type, int id, CBlob &data)
  305. {
  306. //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));
  307. //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));
  308. rxpkt_entry *pos;
  309. ListEntry_ForEach(pos, &m_rxpktList, rxpkt_entry, entry)
  310. {
  311. if (pos->ctx->Req.type == type)
  312. {
  313. ChannelService_Packet_Info pkt;
  314. pkt.type = type;
  315. pkt.sub_type = sub_type;
  316. pkt.id = id;
  317. //pkt.data.m_bManaged = true;
  318. pkt.data = data;
  319. //data.m_bManaged = false;
  320. pos->ctx->SendMessage(pkt);
  321. //break;
  322. }
  323. }
  324. }
  325. void CBizChannelEntity::on_connect(int error, const char *remote_ip, int remote_video_rtp, int remote_video_desc)
  326. {
  327. if (!error) {
  328. if (m_eState == eChannelState_Connecting) {
  329. CSimpleStringA strValue;
  330. ErrorCodeEnum Error = GetFunction()->GetSysVar("VideoWindowInitializeParam", strValue);
  331. if (Error == Error_Succeed) {
  332. int local_view_x;
  333. int local_view_y;
  334. int local_view_cx;
  335. int local_view_cy;
  336. int remote_view_x;
  337. int remote_view_y;
  338. int remote_view_cx;
  339. int remote_view_cy;
  340. int remote_video_width = 0;
  341. int remote_video_height = 0;
  342. {
  343. CSystemStaticInfo Info;
  344. GetFunction()->GetSystemStaticInfo(Info);
  345. if (Info.eScreen == 1)
  346. {
  347. remote_video_width = REC_COMMON_VIDEO_SSM_AGENT_WIDTH;
  348. remote_video_height = REC_COMMON_VIDEO_SSM_AGENT_HEIGHT;
  349. }
  350. else
  351. {
  352. remote_video_width = REC_COMMON_VIDEO_DSM_AGENT_WIDTH;
  353. remote_video_height = REC_COMMON_VIDEO_DSM_AGENT_HEIGHT;
  354. }
  355. }
  356. ParseVideoViewParam((LPCSTR)strValue, local_view_x, local_view_y, local_view_cx, local_view_cy,
  357. remote_view_x, remote_view_y, remote_view_cx, remote_view_cy);
  358. //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,
  359. //remote_view_x, remote_view_y, remote_view_cx, remote_view_cy);
  360. CSimpleStringA param;
  361. if (eMobilePadType == m_eDeviceType)
  362. {
  363. param = BuildVideoDesc(remote_ip, remote_video_rtp, remote_video_width, remote_video_height,
  364. REC_COMMON_VIDEO_FPS_MOBILE_AGENT, 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. }
  367. else if((ePadtype == m_eDeviceType)||(eDesk2SType == m_eDeviceType))
  368. {
  369. param = BuildVideoDesc(remote_ip, remote_video_rtp, remote_video_width, remote_video_height,
  370. REC_COMMON_VIDEO_FPS_MOBILE, 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. } else {
  381. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("get VideoWindowInitializeParam failed!");
  382. bizchan_start_close(m_pChan);
  383. }
  384. }
  385. }
  386. else {
  387. if (m_pChan) {
  388. bizchan_close(m_pChan);
  389. bizchan_destroy(m_pChan);
  390. m_pChan = NULL;
  391. }
  392. ChangeState(eChannelState_Idle);
  393. }
  394. }
  395. void CBizChannelEntity::on_close()
  396. {
  397. if (m_pChan) {
  398. bizchan_close(m_pChan);
  399. bizchan_destroy(m_pChan);
  400. m_pChan = NULL;
  401. }
  402. ChangeState(eChannelState_Idle);
  403. }
  404. void CBizChannelEntity::_on_recv_pkt(int type, int sub_type, int id, const char *pkt, int pkt_size)
  405. {
  406. //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));
  407. NotifyOnRecvPkt *task = new NotifyOnRecvPkt();
  408. task->m_pEntity = this;
  409. task->type = type;
  410. task->sub_type = sub_type;
  411. task->id = id;
  412. task->data.m_bManaged = true;
  413. task->data.m_iLength = pkt_size;
  414. if (pkt_size)
  415. {
  416. task->data.m_pData = new char[pkt_size];
  417. memcpy(task->data.m_pData, pkt, pkt_size);
  418. } else {
  419. task->data.m_pData = NULL;
  420. }
  421. GetFunction()->PostEntityTaskFIFO(task);
  422. }
  423. void CBizChannelEntity::_on_connect(int error, const char *remote_ip, int remote_video_rtp, int remote_video_desc)
  424. {
  425. NotifyOnConnect *task = new NotifyOnConnect();
  426. task->m_pEntity = this;
  427. task->error = error;
  428. task->remote_rtp_ip = remote_ip;
  429. task->remote_video_port = remote_video_rtp;
  430. task->remote_video_desc = remote_video_desc;
  431. GetFunction()->PostEntityTaskFIFO(task);
  432. }
  433. void CBizChannelEntity::_on_close()
  434. {
  435. NotifyOnClose *task = new NotifyOnClose();
  436. task->m_pEntity = this;
  437. GetFunction()->PostEntityTaskFIFO(task);
  438. }
  439. void ChannelServiceSession::Handle_Connect( SpReqAnsContext<ChannelService_Connect_Req, ChannelService_Connect_Ans>::Pointer ctx )
  440. {
  441. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("start connect, %s:%d [%s]", (LPCSTR)ctx->Req.ip, ctx->Req.port, (LPCSTR)ctx->Req.callno);
  442. ErrorCodeEnum Error = m_pEntity->Connect(ctx->Req.ip, ctx->Req.port, ctx->Req.callno, (CallingTypeEnum)ctx->Req.etype);
  443. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("connect Error = %d", Error);
  444. ctx->Answer(Error);
  445. }
  446. void ChannelServiceSession::Handle_Close( SpReqAnsContext<ChannelService_Close_Req, ChannelService_Close_Ans>::Pointer ctx )
  447. {
  448. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("connect close!");
  449. ErrorCodeEnum Error = m_pEntity->Close();
  450. ctx->Answer(Error);
  451. }
  452. void ChannelServiceSession::Handle_GetState( SpReqAnsContext<ChannelService_GetState_Req, ChannelService_GetState_Ans>::Pointer ctx )
  453. {
  454. ctx->Ans.status = state2str(m_pEntity->GetState());
  455. ctx->Answer(Error_Succeed);
  456. }
  457. void ChannelServiceSession::Handle_BeginState( SpSubscribeContext<ChannelService_BeginState_Sub, ChannelService_State_Info>::Pointer ctx )
  458. {
  459. m_pEntity->RegisterState(m_id, ctx);
  460. }
  461. void ChannelServiceSession::Handle_EndState( SpOnewayCallContext<ChannelService_EndState_Info>::Pointer ctx )
  462. {
  463. m_pEntity->UnregisterState(m_id);
  464. }
  465. void ChannelServiceSession::Handle_Send( SpOnewayCallContext<ChannelService_Send_Info>::Pointer ctx )
  466. {
  467. m_pEntity->Send(ctx->Info.type, ctx->Info.compress, ctx->Info.encrypt, ctx->Info.sub_type, ctx->Info.id, ctx->Info.data);
  468. }
  469. void ChannelServiceSession::Handle_BeginRecv( SpSubscribeContext<ChannelService_BeginRecv_Sub, ChannelService_Packet_Info>::Pointer ctx )
  470. {
  471. m_pEntity->RegisterRxPkt(m_id, ctx);
  472. }
  473. void ChannelServiceSession::Handle_EndRecv( SpOnewayCallContext<ChannelService_EndRecv_Info>::Pointer ctx )
  474. {
  475. m_pEntity->UnregisterRxpkt(m_id);
  476. }
  477. void ChannelServiceSession::OnClose( ErrorCodeEnum eErrorCode )
  478. {
  479. m_pEntity->UnregisterRxpkt(m_id);
  480. m_pEntity->UnregisterState(m_id);
  481. }
  482. SP_BEGIN_ENTITY_MAP()
  483. SP_ENTITY(CBizChannelEntity)
  484. SP_END_ENTITY_MAP()