mod_assistantchannel.cpp 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551
  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.PAD")==0){
  119. if (_stricmp(stStaticinfo.strSite,"CMB.FLB")==0){
  120. eType = eMobilePadType;
  121. }
  122. else{
  123. eType = ePadtype;
  124. }
  125. }
  126. else if (_stricmp(stStaticinfo.strMachineType,"RVC.Desk2S")==0){
  127. eType = eDesk2SType;
  128. WORD nMajor = stStaticinfo.MachineVersion.GetMajor();
  129. WORD nMinor = stStaticinfo.MachineVersion.GetMinor();
  130. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("MachineVersion is %d.%d", nMajor, nMinor);
  131. if (2 == nMajor){
  132. eType = eDesk2SIntegratedType;
  133. }
  134. }
  135. else if (_stricmp(stStaticinfo.strMachineType,"RPM.Stand1S")==0){
  136. eType = eRpm1sType;
  137. }
  138. else if (_stricmp(stStaticinfo.strMachineType,"RVC.Desk1S")==0){
  139. eType = eDesk1SType;
  140. }
  141. else{
  142. eType = eStand2sType;
  143. }
  144. if (eType >= 0 && eType < sizeof(Device_Type_Table)/sizeof(char*)){
  145. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("device type is %s.", Device_Type_Table[eType]);
  146. }
  147. return eType;
  148. }
  149. ErrorCodeEnum CBizChannelEntity::__OnClose(ErrorCodeEnum preOperationError)
  150. {
  151. //.....
  152. bizchan_lib_term();
  153. return Error_Succeed;
  154. }
  155. CServerSessionBase* CBizChannelEntity::OnNewSession(const char* pszRemoteEntityName, const char * pszClass)
  156. {
  157. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("%s connected class = %s!", pszRemoteEntityName, pszClass);
  158. return new ChannelServiceSession(this, m_id_seq++);
  159. }
  160. ErrorCodeEnum CBizChannelEntity::Connect(const char *ip, int port, const char *callno, CallingTypeEnum eType)
  161. {
  162. ErrorCodeEnum Error = Error_Succeed;
  163. if (m_eState == eChannelState_Idle)
  164. {
  165. CSystemStaticInfo Info;
  166. bizchan_config_t config = {0};
  167. bizchan_callback_t cb = {0};
  168. GetFunction()->GetSystemStaticInfo(Info);
  169. config.proxy_server = const_cast<char*>(ip);
  170. config.proxy_server_port = port;
  171. config.session_id = const_cast<char*>(((const char*)Info.strTerminalID));
  172. config.call_no = const_cast<char*>(callno);
  173. config.client_id = "";
  174. config.video.desc = MakeDesc(Info.eScreen,m_eDeviceType);
  175. config.video.rtp_port = REC_COMMON_VIDEO_PORT;
  176. cb.user_data = this;
  177. cb.on_close = &__on_close;
  178. cb.on_connect = &__on_connect;
  179. cb.on_destroy = &__on_destroy;
  180. cb.on_recv_pkt = &__on_recv_pkt;
  181. cb.dbg = &__dbg;
  182. int rc = bizchan_create(&config, &cb, &m_pChan);
  183. if (rc == 0)
  184. {
  185. rc = bizchan_start_connect(m_pChan);
  186. }
  187. if (rc != 0)
  188. Error = Error_Unexpect;
  189. else
  190. ChangeState(eChannelState_Connecting);
  191. }
  192. else
  193. {
  194. Error = Error_InvalidState;
  195. }
  196. return Error;
  197. }
  198. ErrorCodeEnum CBizChannelEntity::Close()
  199. {
  200. ErrorCodeEnum Error = Error_Succeed;
  201. if (m_eState == eChannelState_Connecting || m_eState == eChannelState_Connected) {
  202. int rc = bizchan_start_close(m_pChan);
  203. if (rc == 0) {
  204. ChangeState(eChannelState_Closing);
  205. } else {
  206. Error = Error_Unexpect;
  207. }
  208. } else {
  209. Error = Error_InvalidState;
  210. }
  211. return Error_Succeed;
  212. }
  213. ErrorCodeEnum CBizChannelEntity::RegisterState(int id, SpSubscribeContext<ChannelService_BeginState_Sub, ChannelService_State_Info>::Pointer ctx)
  214. {
  215. state_entry *pos;
  216. ListEntry_ForEach(pos, &m_stateList, state_entry, entry)
  217. {
  218. if (pos->id == id)
  219. {
  220. return Error_AlreadyExist;
  221. }
  222. }
  223. pos = new state_entry();
  224. pos->ctx = ctx;
  225. pos->id = id;
  226. ListEntry_AddTail(&m_stateList, &pos->entry);
  227. return Error_Succeed;
  228. }
  229. ErrorCodeEnum CBizChannelEntity::RegisterRxPkt(int id, SpSubscribeContext<ChannelService_BeginRecv_Sub, ChannelService_Packet_Info>::Pointer ctx)
  230. {
  231. rxpkt_entry *pos;
  232. ListEntry_ForEach(pos, &m_rxpktList, rxpkt_entry, entry)
  233. {
  234. if ((pos->id == id)&&(pos->ctx->Req.type == ctx->Req.type))
  235. {
  236. return Error_AlreadyExist;
  237. }
  238. }
  239. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("RegisterRxPkt id = %d",id);
  240. pos = new rxpkt_entry();
  241. pos->id = id;
  242. pos->ctx = ctx;
  243. ListEntry_AddTail(&m_rxpktList, &pos->entry);
  244. return Error_Succeed;
  245. }
  246. void CBizChannelEntity::UnregisterState(int id)
  247. {
  248. state_entry *pos,*n;
  249. ListEntry_ForEachSafe(pos,n, &m_stateList, state_entry, entry) {
  250. if (pos->id == id) {
  251. ListEntry_DeleteNode(&pos->entry);
  252. delete pos;
  253. }
  254. }
  255. }
  256. void CBizChannelEntity::UnregisterRxpkt(int id)
  257. {
  258. rxpkt_entry *pos,*n;
  259. //ListEntry_ForEach(pos, &m_rxpktList, rxpkt_entry, entry)
  260. ListEntry_ForEachSafe(pos, n, &m_rxpktList, rxpkt_entry, entry)
  261. {
  262. if((pos->id == id))
  263. {
  264. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("UnregisterRxpkt id = %d",pos->id);
  265. ListEntry_DeleteNode(&pos->entry);
  266. delete pos;
  267. }
  268. }
  269. }
  270. ErrorCodeEnum CBizChannelEntity::Send(int type, bool compress, bool encrypt, int sub_type, int id, CBlob &data)
  271. {
  272. if (m_eState == eChannelState_Connected) {
  273. //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));
  274. //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));
  275. int rc = bizchan_post_pkt(m_pChan, type, compress, encrypt, sub_type, id, (const char*)data.m_pData, data.m_iLength);
  276. return rc == 0 ? Error_Succeed : Error_NetBroken;
  277. }
  278. else
  279. {
  280. return Error_NetBroken;
  281. }
  282. }
  283. void CBizChannelEntity::ChangeState(int new_state, const char *param)
  284. {
  285. if (m_eState != new_state) {
  286. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("change state from %s to %s", state2str(m_eState), state2str(new_state));
  287. m_eState = new_state;
  288. state_entry *pos;
  289. ListEntry_ForEach(pos, &m_stateList, state_entry, entry) {
  290. ChannelService_State_Info State;
  291. State.state = new_state;
  292. State.status = state2str(new_state);
  293. if (param) {
  294. State.param = param;
  295. }
  296. pos->ctx->SendMessage(State);
  297. }
  298. }
  299. }
  300. void CBizChannelEntity::on_recv_pkt(int type, int sub_type, int id, CBlob &data)
  301. {
  302. //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));
  303. //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));
  304. rxpkt_entry *pos;
  305. ListEntry_ForEach(pos, &m_rxpktList, rxpkt_entry, entry)
  306. {
  307. if (pos->ctx->Req.type == type)
  308. {
  309. ChannelService_Packet_Info pkt;
  310. pkt.type = type;
  311. pkt.sub_type = sub_type;
  312. pkt.id = id;
  313. //pkt.data.m_bManaged = true;
  314. pkt.data = data;
  315. //data.m_bManaged = false;
  316. pos->ctx->SendMessage(pkt);
  317. //break;
  318. }
  319. }
  320. }
  321. void CBizChannelEntity::on_connect(int error, const char *remote_ip, int remote_video_rtp, int remote_video_desc)
  322. {
  323. if (!error) {
  324. if (m_eState == eChannelState_Connecting) {
  325. CSimpleStringA strValue;
  326. ErrorCodeEnum Error = GetFunction()->GetSysVar("VideoWindowInitializeParam", strValue);
  327. if (Error == Error_Succeed) {
  328. int local_view_x;
  329. int local_view_y;
  330. int local_view_cx;
  331. int local_view_cy;
  332. int remote_view_x;
  333. int remote_view_y;
  334. int remote_view_cx;
  335. int remote_view_cy;
  336. int remote_video_width = 0;
  337. int remote_video_height = 0;
  338. {
  339. CSystemStaticInfo Info;
  340. GetFunction()->GetSystemStaticInfo(Info);
  341. if (Info.eScreen == 1)
  342. {
  343. remote_video_width = REC_COMMON_VIDEO_SSM_AGENT_WIDTH;
  344. remote_video_height = REC_COMMON_VIDEO_SSM_AGENT_HEIGHT;
  345. }
  346. else
  347. {
  348. remote_video_width = REC_COMMON_VIDEO_DSM_AGENT_WIDTH;
  349. remote_video_height = REC_COMMON_VIDEO_DSM_AGENT_HEIGHT;
  350. }
  351. }
  352. ParseVideoViewParam((LPCSTR)strValue, local_view_x, local_view_y, local_view_cx, local_view_cy,
  353. remote_view_x, remote_view_y, remote_view_cx, remote_view_cy);
  354. //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,
  355. //remote_view_x, remote_view_y, remote_view_cx, remote_view_cy);
  356. CSimpleStringA param;
  357. if (eMobilePadType == m_eDeviceType)
  358. {
  359. param = BuildVideoDesc(remote_ip, remote_video_rtp, remote_video_width, remote_video_height,
  360. REC_COMMON_VIDEO_FPS_MOBILE_AGENT, local_view_x, local_view_y, local_view_cx, local_view_cy,
  361. remote_view_x, remote_view_y, remote_view_cx, remote_view_cy);
  362. }
  363. else if((ePadtype == m_eDeviceType)||(eDesk2SType == m_eDeviceType))
  364. {
  365. param = BuildVideoDesc(remote_ip, remote_video_rtp, remote_video_width, remote_video_height,
  366. REC_COMMON_VIDEO_FPS_MOBILE, local_view_x, local_view_y, local_view_cx, local_view_cy,
  367. remote_view_x, remote_view_y, remote_view_cx, remote_view_cy);
  368. }
  369. else
  370. {
  371. param = BuildVideoDesc(remote_ip, remote_video_rtp, remote_video_width, remote_video_height,
  372. REC_COMMON_VIDEO_FPS, local_view_x, local_view_y, local_view_cx, local_view_cy,
  373. remote_view_x, remote_view_y, remote_view_cx, remote_view_cy);
  374. }
  375. ChangeState(eChannelState_Connected, (LPCSTR)param);
  376. } else {
  377. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("get VideoWindowInitializeParam failed!");
  378. bizchan_start_close(m_pChan);
  379. }
  380. }
  381. }
  382. else {
  383. if (m_pChan) {
  384. bizchan_close(m_pChan);
  385. bizchan_destroy(m_pChan);
  386. m_pChan = NULL;
  387. }
  388. ChangeState(eChannelState_Idle);
  389. }
  390. }
  391. void CBizChannelEntity::on_close()
  392. {
  393. if (m_pChan) {
  394. bizchan_close(m_pChan);
  395. bizchan_destroy(m_pChan);
  396. m_pChan = NULL;
  397. }
  398. ChangeState(eChannelState_Idle);
  399. }
  400. void CBizChannelEntity::_on_recv_pkt(int type, int sub_type, int id, const char *pkt, int pkt_size)
  401. {
  402. //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));
  403. NotifyOnRecvPkt *task = new NotifyOnRecvPkt();
  404. task->m_pEntity = this;
  405. task->type = type;
  406. task->sub_type = sub_type;
  407. task->id = id;
  408. task->data.m_bManaged = true;
  409. task->data.m_iLength = pkt_size;
  410. if (pkt_size)
  411. {
  412. task->data.m_pData = new char[pkt_size];
  413. memcpy(task->data.m_pData, pkt, pkt_size);
  414. } else {
  415. task->data.m_pData = NULL;
  416. }
  417. GetFunction()->PostEntityTaskFIFO(task);
  418. }
  419. void CBizChannelEntity::_on_connect(int error, const char *remote_ip, int remote_video_rtp, int remote_video_desc)
  420. {
  421. NotifyOnConnect *task = new NotifyOnConnect();
  422. task->m_pEntity = this;
  423. task->error = error;
  424. task->remote_rtp_ip = remote_ip;
  425. task->remote_video_port = remote_video_rtp;
  426. task->remote_video_desc = remote_video_desc;
  427. GetFunction()->PostEntityTaskFIFO(task);
  428. }
  429. void CBizChannelEntity::_on_close()
  430. {
  431. NotifyOnClose *task = new NotifyOnClose();
  432. task->m_pEntity = this;
  433. GetFunction()->PostEntityTaskFIFO(task);
  434. }
  435. void ChannelServiceSession::Handle_Connect( SpReqAnsContext<ChannelService_Connect_Req, ChannelService_Connect_Ans>::Pointer ctx )
  436. {
  437. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("start connect, %s:%d [%s]", (LPCSTR)ctx->Req.ip, ctx->Req.port, (LPCSTR)ctx->Req.callno);
  438. ErrorCodeEnum Error = m_pEntity->Connect(ctx->Req.ip, ctx->Req.port, ctx->Req.callno, (CallingTypeEnum)ctx->Req.etype);
  439. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("connect Error = %d", Error);
  440. ctx->Answer(Error);
  441. }
  442. void ChannelServiceSession::Handle_Close( SpReqAnsContext<ChannelService_Close_Req, ChannelService_Close_Ans>::Pointer ctx )
  443. {
  444. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("connect close!");
  445. ErrorCodeEnum Error = m_pEntity->Close();
  446. ctx->Answer(Error);
  447. }
  448. void ChannelServiceSession::Handle_GetState( SpReqAnsContext<ChannelService_GetState_Req, ChannelService_GetState_Ans>::Pointer ctx )
  449. {
  450. ctx->Ans.status = state2str(m_pEntity->GetState());
  451. ctx->Answer(Error_Succeed);
  452. }
  453. void ChannelServiceSession::Handle_BeginState( SpSubscribeContext<ChannelService_BeginState_Sub, ChannelService_State_Info>::Pointer ctx )
  454. {
  455. m_pEntity->RegisterState(m_id, ctx);
  456. }
  457. void ChannelServiceSession::Handle_EndState( SpOnewayCallContext<ChannelService_EndState_Info>::Pointer ctx )
  458. {
  459. m_pEntity->UnregisterState(m_id);
  460. }
  461. void ChannelServiceSession::Handle_Send( SpOnewayCallContext<ChannelService_Send_Info>::Pointer ctx )
  462. {
  463. m_pEntity->Send(ctx->Info.type, ctx->Info.compress, ctx->Info.encrypt, ctx->Info.sub_type, ctx->Info.id, ctx->Info.data);
  464. }
  465. void ChannelServiceSession::Handle_BeginRecv( SpSubscribeContext<ChannelService_BeginRecv_Sub, ChannelService_Packet_Info>::Pointer ctx )
  466. {
  467. m_pEntity->RegisterRxPkt(m_id, ctx);
  468. }
  469. void ChannelServiceSession::Handle_EndRecv( SpOnewayCallContext<ChannelService_EndRecv_Info>::Pointer ctx )
  470. {
  471. m_pEntity->UnregisterRxpkt(m_id);
  472. }
  473. void ChannelServiceSession::OnClose( ErrorCodeEnum eErrorCode )
  474. {
  475. m_pEntity->UnregisterRxpkt(m_id);
  476. m_pEntity->UnregisterState(m_id);
  477. }
  478. SP_BEGIN_ENTITY_MAP()
  479. SP_ENTITY(CBizChannelEntity)
  480. SP_END_ENTITY_MAP()