Пример #1
0
 /**
  *  获取正式群列表
  *
  *  @param pPdu      收到的packet包指针
  *  @param conn_uuid 该包过来的socket 描述符
  */
 void getNormalGroupList(CImPdu* pPdu, uint32_t conn_uuid)
 {
     IM::Group::IMNormalGroupListReq msg;
     IM::Group::IMNormalGroupListRsp msgResp;
     if(msg.ParseFromArray(pPdu->GetBodyData(), pPdu->GetBodyLength()))
     {
         CImPdu* pPduRes = new CImPdu;
         
         uint32_t nUserId = msg.user_id();
         
         list<IM::BaseDefine::GroupVersionInfo> lsGroup;
         CGroupModel::getInstance()->getUserGroup(nUserId, lsGroup, IM::BaseDefine::GROUP_TYPE_NORMAL);
         msgResp.set_user_id(nUserId);
         for(auto it=lsGroup.begin(); it!=lsGroup.end(); ++it)
         {
             IM::BaseDefine::GroupVersionInfo* pGroupVersion = msgResp.add_group_version_list();
             pGroupVersion->set_group_id(it->group_id());
             pGroupVersion->set_version(it->version());
         }
         
         log("getNormalGroupList. userId=%u, count=%d", nUserId, msgResp.group_version_list_size());
         
         msgResp.set_attach_data(msg.attach_data());
         pPduRes->SetPBMsg(&msgResp);
         pPduRes->SetSeqNum(pPdu->GetSeqNum());
         pPduRes->SetServiceId(IM::BaseDefine::SID_GROUP);
         pPduRes->SetCommandId(IM::BaseDefine::CID_GROUP_NORMAL_LIST_RESPONSE);
         CProxyConn::AddResponsePdu(conn_uuid, pPduRes);
     }
     else
     {
         log("parse pb failed");
     }
 }
Пример #2
0
void ClientConn::_HandleGroupList(CImPdu *pPdu)
{
	IM::Group::IMNormalGroupListRsp msgResp;
	uint32_t nSeqNo = pPdu->GetSeqNum();
	    if(msgResp.ParseFromArray(pPdu->GetBodyData(), pPdu->GetBodyLength()))
    {
		uint32_t nUserId = msgResp.user_id();
        list<IM::BaseDefine::GroupVersionInfo> lsGroupVersionInfo;
		int Cnt = msgResp.group_version_list_size();
        for (uint32_t i=0; i<Cnt; ++i) {
            IM::BaseDefine::GroupVersionInfo groupVersionInfo = msgResp.group_version_list(i);
            lsGroupVersionInfo.push_back(groupVersionInfo);
        }
        m_pCallback->onGroupList(nSeqNo,  nUserId , lsGroupVersionInfo);
    }
    else
    {
        m_pCallback->onError(nSeqNo, pPdu->GetCommandId(), "parse pb error");
    }
}
Пример #3
0
void CGroupChat::HandleGroupNormalResponse(CImPdu* pPdu)
{
    IM::Group::IMNormalGroupListRsp msg;
    CHECK_PB_PARSE_MSG(msg.ParseFromArray(pPdu->GetBodyData(), pPdu->GetBodyLength()));

    uint32_t user_id = msg.user_id();
    uint32_t group_cnt = msg.group_version_list_size();
    CDbAttachData attach_data((uchar_t*)msg.attach_data().c_str(), msg.attach_data().length());

    log("HandleGroupNormalResponse, user_id=%u, group_cnt=%u. ", user_id, group_cnt);

    msg.clear_attach_data();
    pPdu->SetPBMsg(&msg);
    CMsgConn* pConn = CImUserManager::GetInstance()->GetMsgConnByHandle(user_id, attach_data.GetHandle());
    if (pConn)
    {
        pConn->SendPdu(pPdu);
    }
}