当前位置: 首页>>代码示例>>C++>>正文


C++ CImUser::AddOnlineFriend方法代码示例

本文整理汇总了C++中CImUser::AddOnlineFriend方法的典型用法代码示例。如果您正苦于以下问题:C++ CImUser::AddOnlineFriend方法的具体用法?C++ CImUser::AddOnlineFriend怎么用?C++ CImUser::AddOnlineFriend使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CImUser的用法示例。


在下文中一共展示了CImUser::AddOnlineFriend方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: _HandleMsgData

void CRouteServConn::_HandleMsgData(CImPduMsgData* pPdu)
{
	uint32_t from_user_id = pPdu->GetFromUserId();
	uint32_t to_user_id = pPdu->GetToUserId();
	log("HandleMsgData, %u->%u\n", from_user_id, to_user_id);
   
    uint32_t seq_no = pPdu->GetRequestId();
    string from_id_url = idtourl(from_user_id);
    string to_id_url = idtourl(to_user_id);
    uint8_t msg_type = pPdu->GetMsgType();
    
    CImPduClientMsgData pdu(seq_no, from_id_url.c_str(), to_id_url.c_str(), pPdu->GetCreateTime(),
    msg_type, pPdu->GetMsgLen(), pPdu->GetMsgData(), pPdu->GetAttachLen(), pPdu->GetAttachData());
  
    CImUser* pFromImUser = CImUserManager::GetInstance()->GetImUserById(from_user_id);
    CImUser* pToImUser = CImUserManager::GetInstance()->GetImUserById(to_user_id);
    if (pFromImUser) {
        pFromImUser->BroadcastClientMsgData(&pdu, NULL, from_user_id);
        pFromImUser->AddOnlineFriend(to_user_id); // 聊过天就通知上下线消息
	}

    if (pToImUser) {
        pToImUser->BroadcastClientMsgData(&pdu, NULL, from_user_id);
        pToImUser->AddOnlineFriend(from_user_id);
    }
}
开发者ID:9618211,项目名称:TTServer,代码行数:26,代码来源:RouteServConn.cpp

示例2: _HandleFriendStatusNotify

// friend online/off-line notify
void CRouteServConn::_HandleFriendStatusNotify(CImPduFriendStatusNotify* pPdu)
{
	uint32_t user_id = pPdu->GetFromUserId();
	uint32_t user_status = pPdu->GetFromUserStatus();
	uint32_t friend_cnt = pPdu->GetFriendCnt();
	uint32_t* friend_id_list = pPdu->GetFriendIdList();
	string user_id_url = idtourl(user_id);

	log("HandleFriendStatusNotify, from_id=%u, status=%u\n", user_id, user_status);

	// send friend online message to client
	CImPduClientFriendNotify pdu(user_id_url.c_str(), user_status);

	for (uint32_t i = 0; i < friend_cnt; ++i) {
        CImUser* pImUser = CImUserManager::GetInstance()->GetImUserById(friend_id_list[i]);
		if (pImUser) {
			pImUser->BroadcastPdu(&pdu);

			if (user_status == USER_STATUS_ONLINE) {
				pImUser->AddOnlineFriend(user_id);
			} else if (user_status == USER_STATUS_OFFLINE){
				pImUser->RemoveOnlineFriend(user_id);
			}
		}
	}
}
开发者ID:9618211,项目名称:TTServer,代码行数:27,代码来源:RouteServConn.cpp

示例3: _HandleFriendStatusList

void CRouteServConn::_HandleFriendStatusList(CImPduFriendStatusList* pPdu)
{
	uint32_t user_id = pPdu->GetFromUserId();
	uint32_t friend_cnt = pPdu->GetFriendCnt();
	user_stat_t* friend_status_list = pPdu->GetFriendStatList();
	string user_id_url = idtourl(user_id);

	log("HandleOnlineFriendList, from_id=%d\n", user_id);

    CImUser* pImUser = CImUserManager::GetInstance()->GetImUserById(user_id);
    if (!pImUser) {
        return;
    }

	// send online friend status list to client
	CImPduClientOnlineFriendList pduCOFL(pPdu->GetRequestType(), friend_cnt, friend_status_list);
    pImUser->BroadcastPdu(&pduCOFL);
    
    // user don't need to send self status to friend list
	if (pPdu->GetRequestType() == ONLINE_LIST_TYPE_FRIEND_LIST) {
		return;
	}
    
	// send online friend notify packet to the client in the same message server
	CImPduClientFriendNotify pduCFN(user_id_url.c_str(), pImUser->GetIMOnlineStatus());
	for (uint32_t i = 0; i < friend_cnt; i++) {
		pImUser->AddOnlineFriend(friend_status_list[i].user_id);

        CImUser* pFriendUser = CImUserManager::GetInstance()->GetImUserById(friend_status_list[i].user_id);
		if (pFriendUser) {
			//log("notify %u online to %u\n", user_id, friend_status_list[i].user_id);
            pFriendUser->BroadcastPdu(&pduCFN);
			pFriendUser->AddOnlineFriend(user_id);
		}
	}
}
开发者ID:9618211,项目名称:TTServer,代码行数:36,代码来源:RouteServConn.cpp


注:本文中的CImUser::AddOnlineFriend方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。