Exemplo n.º 1
0
void CDBServConn::_HandleGetMsgListResponse(CImPdu *pPdu)
{
    IM::Message::IMGetMsgListRsp 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();
    uint32_t msg_id_begin = msg.msg_id_begin();
    CDbAttachData attach_data((uchar_t*)msg.attach_data().c_str(), msg.attach_data().length());
    uint32_t handle = attach_data.GetHandle();
    
    log("HandleGetMsgListResponse, userId=%u, session_type=%u, opposite_user_id=%u, msg_id_begin=%u, cnt=%u.", user_id, session_type, session_id, msg_id_begin, 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("HandleGetMsgListRepsone, %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);
    }
}
Exemplo n.º 2
0
void CDBServConn::_HandleGetMsgListResponse(CImPdu *pPdu)
{
    IM::Message::IMGetMsgListRsp 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();
    uint32_t msg_id_begin = msg.msg_id_begin();
    CDbAttachData attach_data((uchar_t*)msg.attach_data().c_str(), msg.attach_data().length());
    uint32_t handle = attach_data.GetHandle();
    
    log("HandleGetMsgListResponse, userId=%u, session_type=%u, opposite_user_id=%u, msg_id_begin=%u, cnt=%u.", user_id, session_type, session_id, msg_id_begin, msg_cnt);
    
    SpCMsgConn pMsgConn = CImUserManager::GetInstance()->GetMsgConnByHandle(user_id, handle);
    if (pMsgConn && pMsgConn->IsOpen()) {
        msg.clear_attach_data();
        pPdu->SetPBMsg(&msg);
        pMsgConn->SendPdu(pPdu);
    }
}