void CDBServConn::_HandleRecentSessionResponse(CImPdu *pPdu) { IM::Buddy::IMRecentContactSessionRsp msg; CHECK_PB_PARSE_MSG(msg.ParseFromArray(pPdu->GetBodyData(), pPdu->GetBodyLength())); uint32_t user_id = msg.user_id(); uint32_t session_cnt = msg.contact_session_list_size(); CDbAttachData attach_data((uchar_t*)msg.attach_data().c_str(), msg.attach_data().length()); uint32_t handle = attach_data.GetHandle(); log("HandleRecentSessionResponse, userId=%u, session_cnt=%u", user_id, session_cnt); CMsgConn* pMsgConn = CImUserManager::GetInstance()->GetMsgConnByHandle(user_id, handle); if (pMsgConn && pMsgConn->IsOpen()) { if (pMsgConn->GetCryptoFlag() == 1) { for (int i=0; i < session_cnt; i++) { IM::BaseDefine::ContactSessionInfo* pInfo = msg.mutable_contact_session_list(i); string msg_data = (string)pInfo->latest_msg_data(); pMsgConn->EncryptMsgData(msg_data); //log("HandleRecentSessionResponse, %u data: %s", user_id, msg_data.c_str()); //debug crypto pInfo->set_latest_msg_data(msg_data); } } msg.clear_attach_data(); pPdu->SetPBMsg(&msg); pMsgConn->SendPdu(pPdu); } }
void CDBServConn::_HandleRecentSessionResponse(CImPdu *pPdu) { IM::Buddy::IMRecentContactSessionRsp msg; CHECK_PB_PARSE_MSG(msg.ParseFromArray(pPdu->GetBodyData(), pPdu->GetBodyLength())); uint32_t user_id = msg.user_id(); uint32_t session_cnt = msg.contact_session_list_size(); CDbAttachData attach_data((uchar_t*)msg.attach_data().c_str(), msg.attach_data().length()); uint32_t handle = attach_data.GetHandle(); log("HandleRecentSessionResponse, userId=%u, session_cnt=%u", user_id, session_cnt); SpCMsgConn pMsgConn = CImUserManager::GetInstance()->GetMsgConnByHandle(user_id, handle); if (pMsgConn && pMsgConn->IsOpen()) { msg.clear_attach_data(); pPdu->SetPBMsg(&msg); pMsgConn->SendPdu(pPdu); } }