Пример #1
0
void CDBServConn::_HandleDepartmentResponse(CImPdu *pPdu)
{
    IM::Buddy::IMDepartmentRsp 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 dept_cnt = msg.dept_list_size();
    log("HandleDepartmentResponse, user_id=%u, latest_update_time=%u, dept_cnt=%u.", user_id, latest_update_time, dept_cnt);
    
    CDbAttachData attach_data((uchar_t*)msg.attach_data().c_str(), msg.attach_data().length());
    uint32_t handle = attach_data.GetHandle();
    SpCMsgConn pConn = CImUserManager::GetInstance()->GetMsgConnByHandle(user_id, handle);
    if (pConn && pConn->IsOpen()) {
        msg.clear_attach_data();
        pPdu->SetPBMsg(&msg);
        pConn->SendPdu(pPdu);
    }
}
Пример #2
0
void ClientConn::_HandleDepartMentInfo(CImPdu *pPdu)
{
	IM::Buddy::IMDepartmentRsp msgResp;
	uint32_t nSeqNo = pPdu->GetSeqNum();
	    if(msgResp.ParseFromArray(pPdu->GetBodyData(), pPdu->GetBodyLength()))
    {
		uint32_t nUserId = msgResp.user_id();
		uint32_t lastest_update_time = msgResp.latest_update_time();
        uint32_t departCnt = msgResp.dept_list_size();
        list<IM::BaseDefine::DepartInfo> lsDepartInfo;
        for (uint32_t i=0; i<departCnt; ++i) {
            IM::BaseDefine::DepartInfo departInfo = msgResp.dept_list(i);
            lsDepartInfo.push_back(departInfo);
        }
        m_pCallback->onGetDepartMentInfo(nSeqNo,  nUserId , lastest_update_time,  lsDepartInfo);
    }
    else
    {
        m_pCallback->onError(nSeqNo, pPdu->GetCommandId(), "parse pb error");
    }
}