예제 #1
0
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);
    }
}
예제 #2
0
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);
    }
}
예제 #3
0
void ClientConn::_HandleRecentSession(CImPdu *pPdu)
{
    IM::Buddy::IMRecentContactSessionRsp msgResp;
    uint32_t nSeqNo = pPdu->GetSeqNum();
    if(msgResp.ParseFromArray(pPdu->GetBodyData(), pPdu->GetBodyLength()))
    {
        list<IM::BaseDefine::ContactSessionInfo> lsSession;
        uint32_t nUserId = msgResp.user_id();
        uint32_t nCnt = msgResp.contact_session_list_size();
        for (uint32_t i=0; i<nCnt; ++i) {
            IM::BaseDefine::ContactSessionInfo session = msgResp.contact_session_list(i);
            lsSession.push_back(session);
        }
        m_pCallback->onGetRecentSession(nSeqNo, nUserId, lsSession);
    }
    else
    {
        m_pCallback->onError(nSeqNo, pPdu->GetCommandId(), "parse pb error");
    }
}