示例#1
0
void CDBServConn::_HandleGetMsgByIdResponse(CImPdu *pPdu)
{
    IM::Message::IMGetMsgByIdRsp msg;
    CHECK_PB_PARSE_MSG(msg.ParseFromArray(pPdu->GetBodyData(), pPdu->GetBodyLength()));
    
    uint32_t user_id = msg.user_id();
    uint32_t session_type = msg.session_type();
    uint32_t session_id = msg.session_id();
    uint32_t msg_cnt = msg.msg_list_size();
    CDbAttachData attach_data((uchar_t*)msg.attach_data().c_str(), msg.attach_data().length());
    uint32_t handle = attach_data.GetHandle();
    
    log("HandleGetMsgByIdResponse, userId=%u, session_type=%u, opposite_user_id=%u, cnt=%u.", user_id, session_type, session_id, msg_cnt);
    
    CMsgConn* pMsgConn = CImUserManager::GetInstance()->GetMsgConnByHandle(user_id, handle);
    if (pMsgConn && pMsgConn->IsOpen()) {
        if (pMsgConn->GetCryptoFlag() == 1)
        {
            for (int i=0; i < msg_cnt; i++)
            {
                IM::BaseDefine::MsgInfo* pMsg = msg.mutable_msg_list(i);
                string msg_data = (string)pMsg->msg_data();
                pMsgConn->EncryptMsgData(msg_data);
                //log("HandleGetMsgByIdRepsone, %u->%u data: %s", user_id, session_id, msg_data.c_str()); //debug crypto
                pMsg->set_msg_data(msg_data);
            }
        }
        msg.clear_attach_data();
        pPdu->SetPBMsg(&msg);
        pMsgConn->SendPdu(pPdu);
    }
}
示例#2
0
void CDBServConn::_HandleGetMsgByIdResponse(CImPdu *pPdu)
{
    IM::Message::IMGetMsgByIdRsp msg;
    CHECK_PB_PARSE_MSG(msg.ParseFromArray(pPdu->GetBodyData(), pPdu->GetBodyLength()));
    
    uint32_t user_id = msg.user_id();
    uint32_t session_type = msg.session_type();
    uint32_t session_id = msg.session_id();
    uint32_t msg_cnt = msg.msg_list_size();
    CDbAttachData attach_data((uchar_t*)msg.attach_data().c_str(), msg.attach_data().length());
    uint32_t handle = attach_data.GetHandle();
    
    log("HandleGetMsgByIdResponse, userId=%u, session_type=%u, opposite_user_id=%u, cnt=%u.", user_id, session_type, session_id, msg_cnt);
    
    SpCMsgConn pMsgConn = CImUserManager::GetInstance()->GetMsgConnByHandle(user_id, handle);
    if (pMsgConn && pMsgConn->IsOpen()) {
        msg.clear_attach_data();
        pPdu->SetPBMsg(&msg);
        pMsgConn->SendPdu(pPdu);
    }
}