void getUserInfo(CImPdu* pPdu, uint32_t conn_uuid) { IM::Buddy::IMUsersInfoReq msg; IM::Buddy::IMUsersInfoRsp msgResp; if(msg.ParseFromArray(pPdu->GetBodyData(), pPdu->GetBodyLength())) { CImPdu* pPduRes = new CImPdu; uint32_t from_user_id = msg.user_id(); uint32_t userCount = msg.user_id_list_size(); std::list<uint32_t> idList; for(uint32_t i = 0; i < userCount;++i) { idList.push_back(msg.user_id_list(i)); } std::list<IM::BaseDefine::UserInfo> lsUser; CUserModel::getInstance()->getUsers(idList, lsUser); msgResp.set_user_id(from_user_id); for(list<IM::BaseDefine::UserInfo>::iterator it=lsUser.begin(); it!=lsUser.end(); ++it) { IM::BaseDefine::UserInfo* pUser = msgResp.add_user_info_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, userCnt=%u", from_user_id, userCount); 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_USER_INFO_RESPONSE); CProxyConn::AddResponsePdu(conn_uuid, pPduRes); } else { log("parse pb failed"); } }
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"); } }
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); } }