本文整理汇总了C++中CImPdu::SetPBMsg方法的典型用法代码示例。如果您正苦于以下问题:C++ CImPdu::SetPBMsg方法的具体用法?C++ CImPdu::SetPBMsg怎么用?C++ CImPdu::SetPBMsg使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CImPdu
的用法示例。
在下文中一共展示了CImPdu::SetPBMsg方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sendMessage
uint32_t CClientConn::sendMessage(uint32_t nFromId, uint32_t nToId, IM::BaseDefine::MsgType nType, const string& strMsgData)
{
CImPdu cPdu;
IM::Message::IMMsgData msg;
msg.set_from_user_id(nFromId);
msg.set_to_session_id(nToId);
msg.set_msg_id(0);
msg.set_create_time(time(NULL));
msg.set_msg_type(nType);
msg.set_msg_data(strMsgData);
cPdu.SetPBMsg(&msg);
cPdu.SetServiceId(IM::BaseDefine::SID_MSG);
cPdu.SetCommandId(IM::BaseDefine::CID_MSG_DATA);
uint32_t nSeqNo = m_pSeqAlloctor->getSeq(ALLOCTOR_PACKET);
cPdu.SetSeqNum(nSeqNo);
SendPdu(&cPdu);
return nSeqNo;
}
示例2: getUnreadMsgCounter
void getUnreadMsgCounter(CImPdu* pPdu, uint32_t conn_uuid)
{
IM::Message::IMUnreadMsgCntReq msg;
IM::Message::IMUnreadMsgCntRsp msgResp;
if(msg.ParseFromArray(pPdu->GetBodyData(), pPdu->GetBodyLength()))
{
CImPdu* pPduResp = new CImPdu;
uint32_t nUserId = msg.user_id();
list<IM::BaseDefine::UnreadInfo> lsUnreadCount;
uint32_t nTotalCnt = 0;
CMessageModel::getInstance()->getUnreadMsgCount(nUserId, nTotalCnt, lsUnreadCount);
CGroupMessageModel::getInstance()->getUnreadMsgCount(nUserId, nTotalCnt, lsUnreadCount);
msgResp.set_user_id(nUserId);
msgResp.set_total_cnt(nTotalCnt);
for(auto it= lsUnreadCount.begin(); it!=lsUnreadCount.end(); ++it)
{
IM::BaseDefine::UnreadInfo* pInfo = msgResp.add_unreadinfo_list();
// *pInfo = *it;
pInfo->set_session_id(it->session_id());
pInfo->set_session_type(it->session_type());
pInfo->set_unread_cnt(it->unread_cnt());
pInfo->set_latest_msg_id(it->latest_msg_id());
pInfo->set_latest_msg_data(it->latest_msg_data());
pInfo->set_latest_msg_type(it->latest_msg_type());
pInfo->set_latest_msg_from_user_id(it->latest_msg_from_user_id());
}
log("userId=%d, unreadCnt=%u, totalCount=%u", nUserId, msgResp.unreadinfo_list_size(), nTotalCnt);
msgResp.set_attach_data(msg.attach_data());
pPduResp->SetPBMsg(&msgResp);
pPduResp->SetSeqNum(pPdu->GetSeqNum());
pPduResp->SetServiceId(IM::BaseDefine::SID_MSG);
pPduResp->SetCommandId(IM::BaseDefine::CID_MSG_UNREAD_CNT_RESPONSE);
CProxyConn::AddResponsePdu(conn_uuid, pPduResp);
}
else
{
log("parse pb failed");
}
}
示例3: HandleKickUser
void CImUser::HandleKickUser(CMsgConn* pConn, uint32_t reason)
{
map<uint32_t, CMsgConn*>::iterator it = m_conn_map.find(pConn->GetHandle());
if (it != m_conn_map.end()) {
CMsgConn* pConn = it->second;
if(pConn) {
log("kick service user, user_id=%u.", m_user_id);
IM::Login::IMKickUser msg;
msg.set_user_id(m_user_id);
msg.set_kick_reason((::IM::BaseDefine::KickReasonType)reason);
CImPdu pdu;
pdu.SetPBMsg(&msg);
pdu.SetServiceId(SID_LOGIN);
pdu.SetCommandId(CID_LOGIN_KICK_USER);
pConn->SendPdu(&pdu);
pConn->SetKickOff();
pConn->Close();
}
}
}
示例4: login
uint32_t ClientConn::login(const string &strName, const string &strPass)
{
CImPdu cPdu;
IM::Login::IMLoginReq msg;
msg.set_user_name(strName);
msg.set_password(strPass);
msg.set_online_status(IM::BaseDefine::USER_STATUS_ONLINE);
msg.set_client_type(IM::BaseDefine::CLIENT_TYPE_WINDOWS);
msg.set_client_version("100.0.0");
cPdu.SetPBMsg(&msg);
cPdu.SetServiceId(IM::BaseDefine::DFFX_SID_LOGIN);
cPdu.SetCommandId(IM::BaseDefine::DFFX_CID_LOGIN_REQ_USERLOGIN);
printf("login %d\n",cPdu.GetCommandId());
uint32_t nSeqNo = m_pSeqAlloctor->getSeq(ALLOCTOR_PACKET);
cPdu.SetSeqNum(nSeqNo);
SendPdu(&cPdu);
return nSeqNo;
}
示例5: getGroupInfo
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;
}
示例6: getChgedDepart
void getChgedDepart(CImPdu* pPdu, uint32_t conn_uuid)
{
IM::Buddy::IMDepartmentReq msg;
IM::Buddy::IMDepartmentRsp msgResp;
if (msg.ParseFromArray(pPdu->GetBodyData(), pPdu->GetBodyLength())) {
CImPdu* pPduRes = new CImPdu;
uint32_t nUserId = msg.user_id();
uint32_t nLastUpdate = msg.latest_update_time();
list<uint32_t> lsChangedIds;
CDepartModel::getInstance()->getChgedDeptId(nLastUpdate, lsChangedIds);
list<IM::BaseDefine::DepartInfo> lsDeparts;
CDepartModel::getInstance()->getDepts(lsChangedIds, lsDeparts);
msgResp.set_user_id(nUserId);
msgResp.set_latest_update_time(nLastUpdate);
for(auto it=lsDeparts.begin(); it!=lsDeparts.end(); ++it)
{
IM::BaseDefine::DepartInfo* pDeptInfo = msgResp.add_dept_list();
pDeptInfo->set_dept_id(it->dept_id());
pDeptInfo->set_priority(it->priority());
pDeptInfo->set_dept_name(it->dept_name());
pDeptInfo->set_parent_dept_id(it->parent_dept_id());
pDeptInfo->set_dept_status(it->dept_status());
}
log("userId=%u, last_update=%u, cnt=%u", nUserId, nLastUpdate, lsDeparts.size());
msgResp.set_attach_data(msg.attach_data());
pPduRes->SetPBMsg(&msgResp);
pPduRes->SetSeqNum(pPdu->GetSeqNum());
pPduRes->SetServiceId(IM::BaseDefine::SID_BUDDY_LIST);
pPduRes->SetCommandId(IM::BaseDefine::CID_BUDDY_LIST_DEPARTMENT_RESPONSE);
CProxyConn::AddResponsePdu(conn_uuid, pPduRes);
}
else
{
log("parse pb failed");
}
}
示例7: OnTimer
void CLoginConn::OnTimer(uint64_t curr_tick)
{
if (m_conn_type == LOGIN_CONN_TYPE_CLIENT) {
if (curr_tick > m_last_recv_tick + CLIENT_TIMEOUT) {
Close();
}
} else {
if (curr_tick > m_last_send_tick + SERVER_HEARTBEAT_INTERVAL) {
IM::Other::IMHeartBeat msg;
CImPdu pdu;
pdu.SetPBMsg(&msg);
pdu.SetServiceId(SID_OTHER);
pdu.SetCommandId(CID_OTHER_HEARTBEAT);
SendPdu(&pdu);
}
if (curr_tick > m_last_recv_tick + SERVER_TIMEOUT) {
log("connection to MsgServer timeout ");
Close();
}
}
}
示例8: setGroupPush
/**
* 设置群组信息推送,屏蔽或者取消屏蔽
*
* @param pPdu 收到的packet包指针
* @param conn_uuid 该包过来的socket 描述符
*/
void setGroupPush(CImPdu* pPdu, uint32_t conn_uuid)
{
IM::Group::IMGroupShieldReq msg;
IM::Group::IMGroupShieldRsp msgResp;
if(msg.ParseFromArray(pPdu->GetBodyData(), pPdu->GetBodyLength()))
{
uint32_t nUserId = msg.user_id();
uint32_t nGroupId = msg.group_id();
uint32_t nStatus = msg.shield_status();
if(CGroupModel::getInstance()->isValidateGroupId(nGroupId))
{
CImPdu* pPduRes = new CImPdu;
bool bRet = CGroupModel::getInstance()->setPush(nUserId, nGroupId, IM_GROUP_SETTING_PUSH, nStatus);
msgResp.set_user_id(nUserId);
msgResp.set_group_id(nGroupId);
msgResp.set_result_code(bRet?0:1);
log("userId=%u, groupId=%u, result=%u", nUserId, nGroupId, msgResp.result_code());
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_SHIELD_GROUP_RESPONSE);
CProxyConn::AddResponsePdu(conn_uuid, pPduRes);
}
else
{
log("Invalid group.userId=%u, groupId=%u", nUserId, nGroupId);
}
}
else
{
log("parse pb failed");
}
}
示例9: HandleClientGroupCreateRequest
void CGroupChat::HandleClientGroupCreateRequest(CImPdu* pPdu, CMsgConn* pFromConn)
{
IM::Group::IMGroupCreateReq msg;
CHECK_PB_PARSE_MSG(msg.ParseFromArray(pPdu->GetBodyData(), pPdu->GetBodyLength()));
uint32_t req_user_id = pFromConn->GetUserId();
string group_name = msg.group_name();
uint32_t group_type = msg.group_type();
if (group_type == IM::BaseDefine::GROUP_TYPE_NORMAL) {
log("HandleClientGroupCreateRequest, create normal group failed, req_id=%u, group_name=%s. ", req_user_id, group_name.c_str());
return;
}
string group_avatar = msg.group_avatar();
uint32_t user_cnt = msg.member_id_list_size();
log("HandleClientGroupCreateRequest, req_id=%u, group_name=%s, avatar_url=%s, user_cnt=%u ",
req_user_id, group_name.c_str(), group_avatar.c_str(), user_cnt);
CDBServConn* pDbConn = get_db_serv_conn();
if (pDbConn) {
CDbAttachData attach_data(ATTACH_TYPE_HANDLE, pFromConn->GetHandle(), 0);
msg.set_user_id(req_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::IMGroupCreateRsp msg2;
msg2.set_user_id(req_user_id);
msg2.set_result_code(1);
msg2.set_group_name(group_name);
CImPdu pdu;
pdu.SetPBMsg(&msg2);
pdu.SetServiceId(SID_GROUP);
pdu.SetCommandId(CID_GROUP_CREATE_RESPONSE);
pdu.SetSeqNum(pPdu->GetSeqNum());
pFromConn->SendPdu(&pdu);
}
}
示例10: _HandleUsersStatusRequest
void CRouteConn::_HandleUsersStatusRequest(CImPdu* pPdu)
{
IM::Buddy::IMUsersStatReq msg;
CHECK_PB_PARSE_MSG(msg.ParseFromArray(pPdu->GetBodyData(), pPdu->GetBodyLength()));
uint32_t request_id = msg.user_id();
uint32_t query_count = msg.user_id_list_size();
log("HandleUserStatusReq, req_id=%u, query_count=%u ", request_id, query_count);
IM::Buddy::IMUsersStatRsp msg2;
msg2.set_user_id(request_id);
msg2.set_attach_data(msg.attach_data());
list<user_stat_t> result_list;
user_stat_t status;
for(uint32_t i = 0; i < query_count; i++)
{
IM::BaseDefine::UserStat* user_stat = msg2.add_user_stat_list();
uint32_t user_id = msg.user_id_list(i);
user_stat->set_user_id(user_id);
CUserInfo* pUser = GetUserInfo(user_id);
if (pUser) {
user_stat->set_status((::IM::BaseDefine::UserStatType) pUser->GetStatus()) ;
}
else
{
user_stat->set_status(USER_STATUS_OFFLINE) ;
}
}
// send back query user status
CImPdu pdu;
pdu.SetPBMsg(&msg2);
pdu.SetServiceId(SID_BUDDY_LIST);
pdu.SetCommandId(CID_BUDDY_LIST_USERS_STATUS_RESPONSE);
pdu.SetSeqNum(pPdu->GetSeqNum());
SendPdu(&pdu);
}
示例11: sendMessage
uint32_t ClientConn::sendMessage(uint32_t nFromId, uint32_t nToId, IM::BaseDefine::MsgType nType, const string& strMsgData)
{
CImPdu cPdu;
IM::Message::IMMsgData msg;
msg.set_from_user_id(nFromId);
msg.set_to_session_id(nToId);
msg.set_msg_id(0);
msg.set_create_time(time(NULL));
msg.set_msg_type(nType);
//msg.set_msg_data(strMsgData);
//EncryptMsg
char * pOutData=NULL;
uint32_t nOutLen = 0;
int retCode = EncryptMsg( strMsgData.c_str(), strMsgData.length(), &pOutData, nOutLen);
if (retCode == 0 && nOutLen > 0 && pOutData != 0)
{
msg.set_msg_data( pOutData, nOutLen);
//delete pOutData;
Free(pOutData);
pOutData = NULL;
}
else
{
log("EncryptMsg error:%s\n", strMsgData.c_str());
msg.set_msg_data( strMsgData);
}
cPdu.SetPBMsg(&msg);
cPdu.SetServiceId(IM::BaseDefine::DFFX_SID_MSG);
cPdu.SetCommandId(IM::BaseDefine::DFFX_CID_MSG_DATA);
uint32_t nSeqNo = m_pSeqAlloctor->getSeq(ALLOCTOR_PACKET);
cPdu.SetSeqNum(nSeqNo);
SendPdu(&cPdu);
return nSeqNo;
}
示例12: hasOfflineFile
void hasOfflineFile(CImPdu* pPdu, uint32_t conn_uuid)
{
IM::File::IMFileHasOfflineReq msg;
IM::File::IMFileHasOfflineRsp msgResp;
if(msg.ParseFromArray(pPdu->GetBodyData(), pPdu->GetBodyLength()))
{
CImPdu* pPduRes = new CImPdu;
uint32_t nUserId = msg.user_id();
CFileModel* pModel = CFileModel::getInstance();
list<IM::BaseDefine::OfflineFileInfo> lsOffline;
pModel->getOfflineFile(nUserId, lsOffline);
msgResp.set_user_id(nUserId);
for (list<IM::BaseDefine::OfflineFileInfo>::iterator it=lsOffline.begin();
it != lsOffline.end(); ++it) {
IM::BaseDefine::OfflineFileInfo* pInfo = msgResp.add_offline_file_list();
// *pInfo = *it;
pInfo->set_from_user_id(it->from_user_id());
pInfo->set_task_id(it->task_id());
pInfo->set_file_name(it->file_name());
pInfo->set_file_size(it->file_size());
}
log("userId=%u, count=%u", nUserId, msgResp.offline_file_list_size());
msgResp.set_attach_data(msg.attach_data());
pPduRes->SetPBMsg(&msgResp);
pPduRes->SetSeqNum(pPdu->GetSeqNum());
pPduRes->SetServiceId(IM::BaseDefine::SID_FILE);
pPduRes->SetCommandId(IM::BaseDefine::CID_FILE_HAS_OFFLINE_RES);
CProxyConn::AddResponsePdu(conn_uuid, pPduRes);
}
else
{
log("parse pb failed");
}
}
示例13: 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);
}
}
}
示例14: _QueryChangeMember
void CHttpQuery::_QueryChangeMember(const string& strAppKey, Json::Value &post_json_obj, CHttpConn *pHttpConn)
{
HTTP::CDBServConn *pConn = HTTP::get_db_serv_conn();
if (!pConn) {
log("no connection to RouteServConn ");
char* response_buf = PackSendResult(HTTP_ERROR_SERVER_EXCEPTION, HTTP_ERROR_MSG[9].c_str());
pHttpConn->Send(response_buf, (uint32_t)strlen(response_buf));
pHttpConn->Close();
return;
}
if ( post_json_obj["req_user_id"].isNull()) {
log("no user id ");
char* response_buf = PackSendResult(HTTP_ERROR_PARMENT, HTTP_ERROR_MSG[1].c_str());
pHttpConn->Send(response_buf, (uint32_t)strlen(response_buf));
pHttpConn->Close();
return;
}
if ( post_json_obj["group_id"].isNull() ) {
log("no group id ");
char* response_buf = PackSendResult(HTTP_ERROR_PARMENT, HTTP_ERROR_MSG[1].c_str());
pHttpConn->Send(response_buf, (uint32_t)strlen(response_buf));
pHttpConn->Close();
return;
}
if ( post_json_obj["modify_type"].isNull() ) {
log("no modify_type ");
char* response_buf = PackSendResult(HTTP_ERROR_PARMENT, HTTP_ERROR_MSG[1].c_str());
pHttpConn->Send(response_buf, (uint32_t)strlen(response_buf));
pHttpConn->Close();
return;
}
if (post_json_obj["user_id_list"].isNull()) {
log("no user list ");
char* response_buf = PackSendResult(HTTP_ERROR_PARMENT, HTTP_ERROR_MSG[1].c_str());
pHttpConn->Send(response_buf, (uint32_t)strlen(response_buf));
pHttpConn->Close();
return;
}
try
{
uint32_t user_id = post_json_obj["req_user_id"].asUInt();
uint32_t group_id = post_json_obj["group_id"].asUInt();
uint32_t modify_type = post_json_obj["modify_type"].asUInt();
uint32_t user_cnt = post_json_obj["user_id_list"].size();
log("QueryChangeMember, user_id: %u, group_id: %u, modify type: %u, user_cnt: %u. ",
user_id, group_id, modify_type, user_cnt);
if (!IM::BaseDefine::GroupModifyType_IsValid(modify_type)) {
log("QueryChangeMember, unvalid modify_type");
char* response_buf = PackSendResult(HTTP_ERROR_PARMENT, HTTP_ERROR_MSG[1].c_str());
pHttpConn->Send(response_buf, (uint32_t)strlen(response_buf));
pHttpConn->Close();
return;
}
CDbAttachData attach_data(ATTACH_TYPE_HANDLE, pHttpConn->GetConnHandle());
IM::Group::IMGroupChangeMemberReq msg;
msg.set_user_id(0);
msg.set_change_type((::IM::BaseDefine::GroupModifyType)modify_type);
msg.set_group_id(group_id);
for (uint32_t i = 0; i < user_cnt; i++) {
uint32_t member_id = post_json_obj["user_id_list"][i].asUInt();
msg.add_member_id_list(member_id);
}
msg.set_attach_data(attach_data.GetBuffer(), attach_data.GetLength());
CImPdu pdu;
pdu.SetPBMsg(&msg);
pdu.SetServiceId(IM::BaseDefine::DFFX_SID_GROUP);
pdu.SetCommandId(IM::BaseDefine::DFFX_CID_GROUP_CHANGE_MEMBER_REQUEST);
pConn->SendPdu(&pdu);
}
catch (std::runtime_error msg)
{
log("parse json data failed.");
char* response_buf = PackSendResult(HTTP_ERROR_PARMENT, HTTP_ERROR_MSG[1].c_str());
pHttpConn->Send(response_buf, (uint32_t)strlen(response_buf));
pHttpConn->Close();
}
}
示例15: _HandleUserStatusUpdate
void CRouteConn::_HandleUserStatusUpdate(CImPdu* pPdu)
{
IM::Server::IMUserStatusUpdate msg;
CHECK_PB_PARSE_MSG(msg.ParseFromArray(pPdu->GetBodyData(), pPdu->GetBodyLength()));
uint32_t user_status = msg.user_status();
uint32_t user_id = msg.user_id();
uint32_t client_type = msg.client_type();
log("HandleUserStatusUpdate, status=%u, uid=%u, client_type=%u ", user_status, user_id, client_type);
_UpdateUserStatus(user_id, user_status, client_type);
//用于通知客户端,同一用户在pc端的登录情况
CUserInfo* pUser = GetUserInfo(user_id);
if (pUser)
{
IM::Server::IMServerPCLoginStatusNotify msg2;
msg2.set_user_id(user_id);
if (user_status == IM::BaseDefine::USER_STATUS_OFFLINE)
{
msg2.set_login_status(IM_PC_LOGIN_STATUS_OFF);
}
else
{
msg2.set_login_status(IM_PC_LOGIN_STATUS_ON);
}
CImPdu pdu;
pdu.SetPBMsg(&msg2);
pdu.SetServiceId(SID_OTHER);
pdu.SetCommandId(CID_OTHER_LOGIN_STATUS_NOTIFY);
if (user_status == USER_STATUS_OFFLINE)
{
//pc端下线且无pc端存在,则给msg_server发送一个通知
if (CHECK_CLIENT_TYPE_PC(client_type) && !pUser->IsPCClientLogin())
{
_BroadcastMsg(&pdu);
}
}
else
{
//只要pc端在线,则不管上线的是pc还是移动端,都通知msg_server
if (pUser->IsPCClientLogin())
{
_BroadcastMsg(&pdu);
}
}
}
//状态更新的是pc client端,则通知给所有其他人
if (CHECK_CLIENT_TYPE_PC(client_type))
{
IM::Buddy::IMUserStatNotify msg3;
IM::BaseDefine::UserStat* user_stat = msg3.mutable_user_stat();
user_stat->set_user_id(user_id);
user_stat->set_status((IM::BaseDefine::UserStatType)user_status);
CImPdu pdu2;
pdu2.SetPBMsg(&msg3);
pdu2.SetServiceId(SID_BUDDY_LIST);
pdu2.SetCommandId(CID_BUDDY_LIST_STATUS_NOTIFY);
//用户存在
if (pUser)
{
//如果是pc客户端离线,但是仍然存在pc客户端,则不发送离线通知
//此种情况一般是pc客户端多点登录时引起
if (USER_STATUS_OFFLINE == user_status && pUser->IsPCClientLogin())
{
return;
}
else
{
_BroadcastMsg(&pdu2);
}
}
else//该用户不存在了,则表示是离线状态
{
_BroadcastMsg(&pdu2);
}
}
}