Example #1
0
 void getChangedUser(CImPdu* pPdu, uint32_t conn_uuid)
 {
     IM::Buddy::IMAllUserReq msg;
     IM::Buddy::IMAllUserRsp msgResp;
     if(msg.ParseFromArray(pPdu->GetBodyData(), pPdu->GetBodyLength()))
     {
         CImPdu* pPduRes = new CImPdu;
         
         uint32_t nReqId = msg.user_id();
         uint32_t nLastTime = msg.latest_update_time();
         uint32_t nLastUpdate = CSyncCenter::getInstance()->getLastUpdate();
       
         list<IM::BaseDefine::UserInfo> lsUsers;
         //if( nLastUpdate > nLastTime)
         {
             list<uint32_t> lsIds;
             CUserModel::getInstance()->getRelationId(nReqId, nLastTime, lsIds);
             CUserModel::getInstance()->getUsers(lsIds, lsUsers);
         }
         msgResp.set_user_id(nReqId);
         msgResp.set_latest_update_time(nLastTime);
         for (list<IM::BaseDefine::UserInfo>::iterator it=lsUsers.begin();
              it!=lsUsers.end(); ++it) {
             IM::BaseDefine::UserInfo* pUser = msgResp.add_user_list();
             //            *pUser = *it;
             pUser->set_user_id(it->user_id());
             pUser->set_user_gender(it->user_gender());
             pUser->set_user_nick_name(it->user_nick_name());
             pUser->set_avatar_url(it->avatar_url());
             pUser->set_sign_info(it->sign_info());
             pUser->set_department_id(it->department_id());
             pUser->set_email(it->email());
             pUser->set_user_real_name(it->user_real_name());
             pUser->set_user_tel(it->user_tel());
             pUser->set_user_domain(it->user_domain());
             pUser->set_status(it->status());
             pUser->set_user_type(it->user_type());
         }
         log("userId=%u,nLastUpdate=%u, last_time=%u, userCnt=%u", nReqId,nLastUpdate, nLastTime, msgResp.user_list_size());
         msgResp.set_attach_data(msg.attach_data());
         pPduRes->SetPBMsg(&msgResp);
         pPduRes->SetSeqNum(pPdu->GetSeqNum());
         pPduRes->SetServiceId(IM::BaseDefine::SID_BUDDY_LIST);
         pPduRes->SetCommandId(IM::BaseDefine::CID_BUDDY_LIST_ALL_USER_RESPONSE);
         CProxyConn::AddResponsePdu(conn_uuid, pPduRes);
     }
     else
     {
         log("parse pb failed");
     }
 }
Example #2
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");
    }
}
Example #3
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);
    }
}