Beispiel #1
0
void CGroupChat::HandleClientGroupInfoRequest(CImPdu *pPdu, CMsgConn* pFromConn)
{
    IM::Group::IMGroupInfoListReq msg;
    CHECK_PB_PARSE_MSG(msg.ParseFromArray(pPdu->GetBodyData(), pPdu->GetBodyLength()));
    uint32_t user_id = pFromConn->GetUserId();
    uint32_t group_cnt = msg.group_version_list_size();
    log("HandleClientGroupInfoRequest, user_id=%u, group_cnt=%u. ", user_id, group_cnt);
    CPduAttachData attach_data(ATTACH_TYPE_HANDLE, pFromConn->GetHandle(), 0, NULL);
    
    CDBServConn* pDBConn = get_db_serv_conn();
    if (pDBConn)
    {
        msg.set_user_id(user_id);
        msg.set_attach_data(attach_data.GetBuffer(), attach_data.GetLength());
        pPdu->SetPBMsg(&msg);
        pDBConn->SendPdu(pPdu);
    }
    else
    {
        log("no db connection. ");
        IM::Group::IMGroupInfoListRsp msg2;
        msg2.set_user_id(user_id);
        CImPdu pdu;
        pdu.SetPBMsg(&msg2);
        pdu.SetServiceId(SID_GROUP);
        pdu.SetCommandId(CID_GROUP_INFO_RESPONSE);
        pdu.SetSeqNum(pPdu->GetSeqNum());
        pFromConn->SendPdu(&pdu);
    }
}
Beispiel #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;
}
Beispiel #3
0
 /**
  *  获取群信息
  *
  *  @param pPdu      收到的packet包指针
  *  @param conn_uuid 该包过来的socket 描述符
  */
 void getGroupInfo(CImPdu* pPdu, uint32_t conn_uuid)
 {
     IM::Group::IMGroupInfoListReq msg;
     IM::Group::IMGroupInfoListRsp msgResp;
     if(msg.ParseFromArray(pPdu->GetBodyData(), pPdu->GetBodyLength()))
     {
         CImPdu* pPduRes = new CImPdu;
         uint32_t nUserId = msg.user_id();
         uint32_t nGroupCnt = msg.group_version_list_size();
         
         map<uint32_t, IM::BaseDefine::GroupVersionInfo> mapGroupId;
         for(uint32_t i=0; i<nGroupCnt; ++i)
         {
             IM::BaseDefine::GroupVersionInfo groupInfo = msg.group_version_list(i);
             if(CGroupModel::getInstance()->isValidateGroupId(groupInfo.group_id()))
             {
                 mapGroupId[groupInfo.group_id()] = groupInfo;
             }
         }
         list<IM::BaseDefine::GroupInfo> lsGroupInfo;
         CGroupModel::getInstance()->getGroupInfo(mapGroupId, lsGroupInfo);
         
         msgResp.set_user_id(nUserId);
         for(auto it=lsGroupInfo.begin(); it!=lsGroupInfo.end(); ++it)
         {
             IM::BaseDefine::GroupInfo* pGroupInfo = msgResp.add_group_info_list();
 //            *pGroupInfo = *it;
             pGroupInfo->set_group_id(it->group_id());
             pGroupInfo->set_version(it->version());
             pGroupInfo->set_group_name(it->group_name());
             pGroupInfo->set_group_avatar(it->group_avatar());
             pGroupInfo->set_group_creator_id(it->group_creator_id());
             pGroupInfo->set_group_type(it->group_type());
             pGroupInfo->set_shield_status(it->shield_status());
             uint32_t nGroupMemberCnt = it->group_member_list_size();
             for (uint32_t i=0; i<nGroupMemberCnt; ++i)
             {
                 uint32_t userId = it->group_member_list(i);
                 pGroupInfo->add_group_member_list(userId);
             }
         }
         
         log("userId=%u, requestCount=%u", nUserId, nGroupCnt);
         
         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_INFO_RESPONSE);
         CProxyConn::AddResponsePdu(conn_uuid, pPduRes);
     }
     else
     {
         log("parse pb failed");
     }
 }