예제 #1
0
파일: GroupChat.cpp 프로젝트: hgl888/Server
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);
    }
}
예제 #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;
}