本文整理汇总了C++中CImPdu::GetBuffer方法的典型用法代码示例。如果您正苦于以下问题:C++ CImPdu::GetBuffer方法的具体用法?C++ CImPdu::GetBuffer怎么用?C++ CImPdu::GetBuffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CImPdu
的用法示例。
在下文中一共展示了CImPdu::GetBuffer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleGroupInfoResponse
void CGroupChat::HandleGroupInfoResponse(CImPdu* pPdu)
{
IM::Group::IMGroupInfoListRsp msg;
CHECK_PB_PARSE_MSG(msg.ParseFromArray(pPdu->GetBodyData(), pPdu->GetBodyLength()));
uint32_t user_id = msg.user_id();
uint32_t group_cnt = msg.group_info_list_size();
CPduAttachData pduAttachData((uchar_t*)msg.attach_data().c_str(), msg.attach_data().length());
log("HandleGroupInfoResponse, user_id=%u, group_cnt=%u. ", user_id, group_cnt);
//此处是查询成员时使用,主要用于群消息从数据库获得msg_id后进行发送,一般此时group_cnt = 1
if (pduAttachData.GetPduLength() > 0 && group_cnt > 0)
{
IM::BaseDefine::GroupInfo group_info = msg.group_info_list(0);
uint32_t group_id = group_info.group_id();
log("GroupInfoRequest is send by server, group_id=%u ", group_id);
std::set<uint32_t> group_member_set;
for (uint32_t i = 0; i < group_info.group_member_list_size(); i++)
{
uint32_t member_user_id = group_info.group_member_list(i);
group_member_set.insert(member_user_id);
}
if (group_member_set.find(user_id) == group_member_set.end())
{
log("user_id=%u is not in group, group_id=%u. ", user_id, group_id);
return;
}
IM::Message::IMMsgData msg2;
CHECK_PB_PARSE_MSG(msg2.ParseFromArray(pduAttachData.GetPdu(), pduAttachData.GetPduLength()));
CImPdu pdu;
pdu.SetPBMsg(&msg2);
pdu.SetServiceId(SID_MSG);
pdu.SetCommandId(CID_MSG_DATA);
//Push相关
IM::Server::IMGroupGetShieldReq msg3;
msg3.set_group_id(group_id);
msg3.set_attach_data(pdu.GetBodyData(), pdu.GetBodyLength());
for (uint32_t i = 0; i < group_info.group_member_list_size(); i++)
{
uint32_t member_user_id = group_info.group_member_list(i);
msg3.add_user_id(member_user_id);
CImUser* pToImUser = CImUserManager::GetInstance()->GetImUserById(member_user_id);
if (pToImUser)
{
CMsgConn* pFromConn = NULL;
if( member_user_id == user_id )
{
uint32_t reqHandle = pduAttachData.GetHandle();
if(reqHandle != 0)
pFromConn = CImUserManager::GetInstance()->GetMsgConnByHandle(user_id, reqHandle);
}
pToImUser->BroadcastData(pdu.GetBuffer(), pdu.GetLength(), pFromConn);
}
}
CImPdu pdu2;
pdu2.SetPBMsg(&msg3);
pdu2.SetServiceId(SID_OTHER);
pdu2.SetCommandId(CID_OTHER_GET_SHIELD_REQ);
CDBServConn* pDbConn = get_db_serv_conn();
if (pDbConn)
{
pDbConn->SendPdu(&pdu2);
}
}
else if (pduAttachData.GetPduLength() == 0)
{
//正常获取群信息的返回
CMsgConn* pConn = CImUserManager::GetInstance()->GetMsgConnByHandle(user_id, pduAttachData.GetHandle());
if (pConn)
{
msg.clear_attach_data();
pPdu->SetPBMsg(&msg);
pConn->SendPdu(pPdu);
}
}
}