Beispiel #1
0
void CDBServConn::_HandleUsersInfoResponse(CImPdu* pPdu)
{
    IM::Buddy::IMUsersInfoRsp msg;
    CHECK_PB_PARSE_MSG(msg.ParseFromArray(pPdu->GetBodyData(), pPdu->GetBodyLength()));

    uint32_t user_id = msg.user_id();
    uint32_t user_cnt = msg.user_info_list_size();
    CDbAttachData attach_data((uchar_t*)msg.attach_data().c_str(), msg.attach_data().length());
	uint32_t handle = attach_data.GetHandle();
    
    log("HandleUsersInfoResp, user_id=%u, user_cnt=%u.", user_id, user_cnt);
    
    SpCMsgConn pMsgConn = CImUserManager::GetInstance()->GetMsgConnByHandle(user_id, handle);
    if (pMsgConn && pMsgConn->IsOpen()) {
        msg.clear_attach_data();
        pPdu->SetPBMsg(&msg);
        pMsgConn->SendPdu(pPdu);
    }
}
Beispiel #2
0
void ClientConn::_HandleUserInfo(CImPdu* pPdu)
{
    IM::Buddy::IMUsersInfoRsp msgResp;
    uint32_t nSeqNo = pPdu->GetSeqNum();
    if(msgResp.ParseFromArray(pPdu->GetBodyData(), pPdu->GetBodyLength()))
    {
        uint32_t userCnt = msgResp.user_info_list_size();
        list<IM::BaseDefine::UserInfo> lsUser;
        for (uint32_t i=0; i<userCnt; ++i) {
            IM::BaseDefine::UserInfo userInfo = msgResp.user_info_list(i);
            lsUser.push_back(userInfo);
        }
        m_pCallback->onGetUserInfo(nSeqNo, lsUser);
    }
    else
    {
        m_pCallback->onError(nSeqNo, pPdu->GetCommandId(), "parse pb error");
    }
}