示例#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
uint32_t ClientConn::getGroupInfo(uint32_t nUserId , const list<IM::BaseDefine::GroupVersionInfo> &lsGroupVersionInfo)
{
	CImPdu cPdu;
	IM::Group::IMGroupInfoListReq msg;
	msg.set_user_id(nUserId);
	
	for(const auto &vi:lsGroupVersionInfo)
	{
		IM::BaseDefine::GroupVersionInfo* pGroupVersionInfo = msg.add_group_version_list();
		pGroupVersionInfo->set_group_id(vi.group_id());
		pGroupVersionInfo->set_version(0);
	}

	cPdu.SetPBMsg(&msg);
    cPdu.SetServiceId(IM::BaseDefine::SID_GROUP);
    cPdu.SetCommandId(IM::BaseDefine::CID_GROUP_INFO_REQUEST);
    uint32_t nSeqNo = m_pSeqAlloctor->getSeq(ALLOCTOR_PACKET);
    cPdu.SetSeqNum(nSeqNo);
    SendPdu(&cPdu);
    return nSeqNo;
}