Exemplo n.º 1
0
void ClientConn::_HandleUser(CImPdu* pPdu)
{
    IM::Buddy::IMAllUserRsp msgResp;
    uint32_t nSeqNo = pPdu->GetSeqNum();
    if(msgResp.ParseFromArray(pPdu->GetBodyData(), pPdu->GetBodyLength()))
    {
        uint32_t userCnt = msgResp.user_list_size();
        list<IM::BaseDefine::UserInfo> lsUsers;
        for(uint32_t i=0; i<userCnt; ++i)
        {
            IM::BaseDefine::UserInfo cUserInfo = msgResp.user_list(i);
            lsUsers.push_back(cUserInfo);
        }
        m_pCallback->onGetChangedUser(nSeqNo, lsUsers);
    }
    else
    {
        m_pCallback->onError(nSeqNo, pPdu->GetCommandId(), "parse pb error");
    }
}
Exemplo n.º 2
0
void CDBServConn::_HandleAllUserResponse(CImPdu *pPdu)
{
    IM::Buddy::IMAllUserRsp msg;
    CHECK_PB_PARSE_MSG(msg.ParseFromArray(pPdu->GetBodyData(), pPdu->GetBodyLength()));
    
    uint32_t user_id = msg.user_id();
    uint32_t latest_update_time = msg.latest_update_time();
    uint32_t user_cnt = msg.user_list_size();
    CDbAttachData attach_data((uchar_t*)msg.attach_data().c_str(), msg.attach_data().length());
    uint32_t handle = attach_data.GetHandle();
    
    log("HandleAllUserResponse, userId=%u, latest_update_time=%u, user_cnt=%u", user_id, latest_update_time, user_cnt);
    
    SpCMsgConn pMsgConn = CImUserManager::GetInstance()->GetMsgConnByHandle(user_id, handle);
    
    if (pMsgConn && pMsgConn->IsOpen())
    {
        msg.clear_attach_data();
        pPdu->SetPBMsg(&msg);
        pMsgConn->SendPdu(pPdu);
    }
}