Пример #1
0
void getChgedDepart(CImPdu* pPdu, uint32_t conn_uuid)
{
    IM::Buddy::IMDepartmentReq msg;
    IM::Buddy::IMDepartmentRsp msgResp;
    if (msg.ParseFromArray(pPdu->GetBodyData(), pPdu->GetBodyLength())) {

        CImPdu* pPduRes = new CImPdu;

        uint32_t nUserId = msg.user_id();
        uint32_t nLastUpdate = msg.latest_update_time();
        list<uint32_t> lsChangedIds;
        CDepartModel::getInstance()->getChgedDeptId(nLastUpdate, lsChangedIds);
        list<IM::BaseDefine::DepartInfo> lsDeparts;
        CDepartModel::getInstance()->getDepts(lsChangedIds, lsDeparts);

        msgResp.set_user_id(nUserId);
        msgResp.set_latest_update_time(nLastUpdate);
        for(auto it=lsDeparts.begin(); it!=lsDeparts.end(); ++it)
        {
            IM::BaseDefine::DepartInfo* pDeptInfo = msgResp.add_dept_list();
            pDeptInfo->set_dept_id(it->dept_id());
            pDeptInfo->set_priority(it->priority());
            pDeptInfo->set_dept_name(it->dept_name());
            pDeptInfo->set_parent_dept_id(it->parent_dept_id());
            pDeptInfo->set_dept_status(it->dept_status());
        }
        log("userId=%u, last_update=%u, cnt=%u", nUserId, nLastUpdate, lsDeparts.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_DEPARTMENT_RESPONSE);
        CProxyConn::AddResponsePdu(conn_uuid, pPduRes);

    }
    else
    {
        log("parse pb failed");
    }
}
Пример #2
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);
    }
}
Пример #3
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");
    }
}