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


C++ CImUser类代码示例

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


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

示例1: CHECK_PB_PARSE_MSG

void CRouteServConn::_HandleClientDelFriendNotify(CImPdu* pPdu)
{
	IM::Buddy::IMCommonOperFriendRes msg;
	CHECK_PB_PARSE_MSG(msg.ParseFromArray(pPdu->GetBodyData(), pPdu->GetBodyLength()));
	
	log(" user_id=%d friend_id=%d.", msg.user_id(), msg.friend_id());

	//send to other client
	CImUser* pFromImUser = CImUserManager::GetInstance()->GetImUserById(msg.user_id());
	if (pFromImUser)
	{
		pPdu->SetCommandId(DFFX_CID_BUDDY_LIST_DELFRIEND_RES);
		pFromImUser->BroadcastPdu(pPdu);
	}
	
	// 2.send notify to myfriend
	uint32_t to_user_id = msg.friend_id();
	CImUser* pToImUser = CImUserManager::GetInstance()->GetImUserById(to_user_id);
	if (pToImUser)
	{
		pPdu->SetCommandId(DFFX_CID_BUDDY_LIST_DELFRIEND_NOTIFY);
		pToImUser->BroadcastPdu(pPdu);
	}	

}
开发者ID:hlyces,项目名称:teamtalk_TT,代码行数:25,代码来源:RouteServConn.cpp

示例2: CHECK_PB_PARSE_MSG

void CRouteServConn::_HandlePCLoginStatusNotify(CImPdu *pPdu)
{
    IM::Server::IMServerPCLoginStatusNotify msg;
    CHECK_PB_PARSE_MSG(msg.ParseFromArray(pPdu->GetBodyData(), pPdu->GetBodyLength()));

    uint32_t user_id = msg.user_id();
    uint32_t login_status = msg.login_status();
    log("HandlePCLoginStatusNotify, user_id=%u, login_status=%u ", user_id, login_status);
    
    CImUser* pUser = CImUserManager::GetInstance()->GetImUserById(user_id);
    if (pUser)
    {
        pUser->SetPCLoginStatus(login_status);
        IM::Buddy::IMPCLoginStatusNotify msg2;
        msg2.set_user_id(user_id);
        if (IM_PC_LOGIN_STATUS_ON == login_status)
        {
            msg2.set_login_stat(::IM::BaseDefine::USER_STATUS_ONLINE);
        }
        else
        {
            msg2.set_login_stat(::IM::BaseDefine::USER_STATUS_OFFLINE);
        }
        CImPdu pdu;
        pdu.SetPBMsg(&msg2);
        pdu.SetServiceId(IM::BaseDefine::SID_BUDDY_LIST);
        pdu.SetCommandId(IM::BaseDefine::CID_BUDDY_LIST_PC_LOGIN_STATUS_NOTIFY);
        pUser->BroadcastPduToMobile(&pdu);
    }
}
开发者ID:narychen,项目名称:eggie,代码行数:30,代码来源:RouteServConn.cpp

示例3: idtourl

// 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

示例4: log

void CRouteServConn::_HandleGroupP2PMsg(CImPduGroupP2PMessageResponse* pPdu)
{
    uint32_t  result = pPdu->GetResult();
    uint32_t  from_user_id = pPdu->GetReqUserId();
    uint32_t* toUserList = pPdu->GetUserList();
    log("_HandleGroupP2PMsg, from_user_id = %u, result = %u, to_user_cnt = %u.\n", from_user_id, result, pPdu->GetUserCnt());
    
    if(result != 0 || !toUserList)
    return;
    
    for (int i = 0; i < pPdu->GetUserCnt(); ++i) {
        uint32_t to_user_id = toUserList[i];
        CImUser* pToImUser = CImUserManager::GetInstance()->GetImUserById(to_user_id);
        if (pToImUser) {
            uint32_t seq_no = 0;
            string from_id_url = idtourl(from_user_id);
            string to_id_url = idtourl(to_user_id);
            
            CImPduClientP2PCmdMsg pdu(seq_no, from_id_url.c_str(), to_id_url.c_str(), pPdu->GetMsgDataLen(),
                                      pPdu->GetMsgData());
            pToImUser->BroadcastPdu(&pdu);
        }
    }

}
开发者ID:9618211,项目名称:TTServer,代码行数:25,代码来源:RouteServConn.cpp

示例5: CHECK_PB_PARSE_MSG

void CDBServConn::_HandleMsgData(CImPdu *pPdu)
{
    IM::Message::IMMsgData msg;
    CHECK_PB_PARSE_MSG(msg.ParseFromArray(pPdu->GetBodyData(), pPdu->GetBodyLength()));
    if (CHECK_MSG_TYPE_GROUP(msg.msg_type())) {
        s_group_chat->HandleGroupMessage(pPdu);
        return;
    }
    
    uint32_t from_user_id = msg.from_user_id();
    uint32_t to_user_id = msg.to_session_id();
    uint32_t msg_id = msg.msg_id();
    if (msg_id == 0) {
        log("HandleMsgData, write db failed, %u->%u.", from_user_id, to_user_id);
        return;
    }
    
    uint8_t msg_type = msg.msg_type();
    CDbAttachData attach_data((uchar_t*)msg.attach_data().c_str(), msg.attach_data().length());
    uint32_t handle = attach_data.GetHandle();
    
    log("HandleMsgData, from_user_id=%u, to_user_id=%u, msg_id=%u.", from_user_id, to_user_id, msg_id);
    
    CMsgConn* pMsgConn = CImUserManager::GetInstance()->GetMsgConnByHandle(from_user_id, attach_data.GetHandle());
    if (pMsgConn)
    {
        IM::Message::IMMsgDataAck msg2;
        msg2.set_user_id(from_user_id);
        msg2.set_msg_id(msg_id);
        msg2.set_session_id(to_user_id);
        msg2.set_session_type(::IM::BaseDefine::SESSION_TYPE_SINGLE);

        pMsgConn->SendPdu(SID_MSG, CID_MSG_DATA_ACK, msg2);
    }
    
    CRouteServConn* pRouteConn = get_route_serv_conn();
    if (pRouteConn) {
        pRouteConn->SendPdu(pPdu);
    }
    
    msg.clear_attach_data();
    pPdu->SetPBMsg(&msg);
    CImUser* pFromImUser = CImUserManager::GetInstance()->GetImUserById(from_user_id);
    CImUser* pToImUser = CImUserManager::GetInstance()->GetImUserById(to_user_id);
    pPdu->SetSeqNum(0);
    if (pFromImUser) {
        pFromImUser->BroadcastClientMsgData(pPdu, msg_id, pMsgConn, from_user_id);
    }

    if (pToImUser) {
        pToImUser->BroadcastClientMsgData(pPdu, msg_id, NULL, from_user_id);
    }
    
    IM::Server::IMGetDeviceTokenReq msg3;
    msg3.add_user_id(to_user_id);
    msg3.set_attach_data(pPdu->GetBodyData(), pPdu->GetBodyLength());

    SendPdu(SID_OTHER, CID_OTHER_GET_DEVICE_TOKEN_REQ, msg3);
}
开发者ID:zergl,项目名称:TeamTalk,代码行数:59,代码来源:DBServConn.cpp

示例6: GetImUserById

CMsgConn* CImUserManager::GetMsgConnByHandle(uint32_t user_id, uint32_t handle)
{
    CMsgConn* pMsgConn = NULL;
    CImUser* pImUser = GetImUserById(user_id);
    if (pImUser) {
        pMsgConn = pImUser->GetMsgConn(handle);
    }
    return pMsgConn;
}
开发者ID:ryanspeng,项目名称:yxim,代码行数:9,代码来源:ImUser.cpp

示例7: _SendPduToUser

void CGroupChat::_SendPduToUser(CImPdu* pPdu, uint32_t user_id, CMsgConn* pReqConn)
{
    if(!pPdu) {
        return;
    }
    CImUser* pToUser = CImUserManager::GetInstance()->GetImUserById(user_id);
    if(pToUser) {
        pToUser->BroadcastPdu(pPdu, pReqConn);
    }
}
开发者ID:hgl888,项目名称:Server,代码行数:10,代码来源:GroupChat.cpp

示例8: from_id_url

void CFileHandler::HandleClientFileRequest(CMsgConn* pMsgConn, CImPduClientFileRequest* pPdu)
{
	string from_id_url(pPdu->GetFromId(), pPdu->GetFromIdLen());
	uint32_t from_id = urltoid(from_id_url.c_str());
	string to_id_url(pPdu->GetToId(), pPdu->GetToIdLen());
	uint32_t to_id = urltoid(to_id_url.c_str());
	string file_name(pPdu->GetFileName(), pPdu->GetFileNameLen());
	uint32_t file_size = pPdu->GetFileSize();
	log("HandleClientFileRequest, %u->%u, fileName: %s\n", from_id, to_id, file_name.c_str());

    CPduAttachData attach(ATTACH_TYPE_HANDLE, pMsgConn->GetHandle(), 0, NULL, 0);

    CImUser* pUser = CImUserManager::GetInstance()->GetImUserById(to_id);
    if (pUser)
    {
        uint32_t client_type_flag = pUser->GetClientTypeFlag();
        //to_user has pc_client in this msg_server
        if ((client_type_flag & CLIENT_TYPE_FLAG_BOTH) == CLIENT_TYPE_FLAG_PC)
        {
            CFileServConn* pFileConn = get_random_file_serv_conn();
            if (pFileConn)
            {
                CImPduMsgFileTransferReq pdu(from_id, to_id, file_name.c_str(), file_size,
                                    FILE_TYPE_ONLINE, attach.GetLength(), attach.GetBuffer());
                pdu.SetReserved(pPdu->GetReserved());
                pFileConn->SendPdu(&pdu);
            }
            else
            {
                log("HandleClientFileRequest, no file server.\n");
                CImPduClientFileResponse pdu2(REFUSE_REASON_NO_FILE_SERVER, from_id_url.c_str(),
                                              to_id_url.c_str(), file_name.c_str(), NULL, NULL, 0);
                pdu2.SetReserved(pPdu->GetReserved());
                pMsgConn->SendPdu(&pdu2);
            }
            return;
        }
    }
    else
    {
        //no pc_client in this msg_server, check it from route_server
        CRouteServConn* pConn = get_route_serv_conn();
        CPduAttachData pduAttachData(ATTACH_TYPE_HANDLE_AND_PDU, pMsgConn->GetHandle(),
                                     pPdu->GetLength(), pPdu->GetBuffer());
        CImPduUserClientTypeRequest pdu3(to_id, pduAttachData.GetLength(), pduAttachData.GetBuffer());
        pdu3.SetReserved(pPdu->GetReserved());
        pConn->SendPdu(&pdu3);
    }
}
开发者ID:9618211,项目名称:TTServer,代码行数:49,代码来源:FileHandler.cpp

示例9: GetUserConnCnt

void CImUserManager::GetUserConnCnt(list<user_conn_t>* user_conn_list, uint32_t& total_conn_cnt)
{
    total_conn_cnt = 0;
    CImUser* pImUser = NULL;
    for (ImUserMap_t::iterator it = m_im_user_map.begin(); it != m_im_user_map.end(); it++)
    {
        pImUser = (CImUser*)it->second;
        if (pImUser->IsValidate())
        {
            user_conn_t user_conn_cnt = pImUser->GetUserConn();
            user_conn_list->push_back(user_conn_cnt);
            total_conn_cnt += user_conn_cnt.conn_cnt;
        }
    }
}
开发者ID:ryanspeng,项目名称:yxim,代码行数:15,代码来源:ImUser.cpp

示例10: CHECK_PB_PARSE_MSG

void CDBServConn::_HandleChangeAvatarResponse(CImPdu* pPdu)
{
    IM::Buddy::IMChangeAvatarRsp msg;
    CHECK_PB_PARSE_MSG(msg.ParseFromArray(pPdu->GetBodyData(), pPdu->GetBodyLength()));

    uint32_t user_id = msg.user_id();
    uint32_t result = msg.result_code();
    
	log("HandleChangeAvatarResp, user_id=%u, result=%u.", user_id, result);
    
    CImUser* pUser = CImUserManager::GetInstance()->GetImUserById(user_id);
    if (NULL != pUser) {
        msg.clear_attach_data();
        pPdu->SetPBMsg(&msg);
        pUser->BroadcastPdu(pPdu);
    }
}
开发者ID:narychen,项目名称:eggie,代码行数:17,代码来源:DBServConn.cpp

示例11: file_name

void CFileHandler::HandleFileNotify(CImPduFileNotify *pPdu)
{
    uint32_t from_user_id = pPdu->GetFromId();
    uint32_t to_user_id = pPdu->GetToId();
    string file_name(pPdu->GetFileName(), pPdu->GetFileNameLen());
    uint32_t file_size = pPdu->GetFileSize();
    string task_id(pPdu->GetTaskId(), pPdu->GetTaskIdLen());
    string listen_ip(pPdu->GetListenIp(), pPdu->GetListenIpLen());
    uint32_t listen_port = pPdu->GetListenPort();
    log("HandleFileNotify, from_id: %u, to_id: %u, file_name: %s, task_id: %s, file_server_ip: %s,\
        file_server_port: %u.\n", from_user_id, to_user_id, file_name.c_str(), task_id.c_str(),
        listen_ip.c_str(), listen_port);
    CImUser* pUser = CImUserManager::GetInstance()->GetImUserById(to_user_id);
    if (pUser) {
        CImPduClientFileNotify pdu(idtourl(from_user_id), idtourl(to_user_id), file_name.c_str(),
                                   file_size, task_id.c_str(), listen_ip.c_str(), listen_port);
        pUser->BroadcastPdu(&pdu);
    }
}
开发者ID:9618211,项目名称:TTServer,代码行数:19,代码来源:FileHandler.cpp

示例12: GetOnlineUserInfo

void CImUserManager::GetOnlineUserInfo(list<user_stat_t>* online_user_info)
{
    user_stat_t status;
    CImUser* pImUser = NULL;
    for (ImUserMap_t::iterator it = m_im_user_map.begin(); it != m_im_user_map.end(); it++) {
        pImUser = (CImUser*)it->second;
        if (pImUser->IsValidate()) {
            map<uint32_t, CMsgConn*>& ConnMap = pImUser->GetMsgConnMap();
            for (map<uint32_t, CMsgConn*>::iterator it = ConnMap.begin(); it != ConnMap.end(); it++)
            {
                CMsgConn* pConn = it->second;
                if (pConn->IsOpen())
                {
                    status.user_id = pImUser->GetUserId();
                    status.client_type = pConn->GetClientType();
                    status.status = pConn->GetOnlineStatus();
                    online_user_info->push_back(status);
                }
            }
        }
    }
}
开发者ID:ryanspeng,项目名称:yxim,代码行数:22,代码来源:ImUser.cpp

示例13: BroadcastPdu

void CImUserManager::BroadcastPdu(CImPdu* pdu, uint32_t client_type_flag)
{
    CImUser* pImUser = NULL;
    for (ImUserMap_t::iterator it = m_im_user_map.begin(); it != m_im_user_map.end(); it++)
    {
        pImUser = (CImUser*)it->second;
        if (pImUser->IsValidate())
        {
            switch (client_type_flag) {
                case CLIENT_TYPE_FLAG_PC:
                    pImUser->BroadcastPduWithOutMobile(pdu);
                    break;
                case CLIENT_TYPE_FLAG_MOBILE:
                    pImUser->BroadcastPduToMobile(pdu);
                    break;
                case CLIENT_TYPE_FLAG_BOTH:
                    pImUser->BroadcastPdu(pdu);
                    break;
                default:
                    break;
            }
        }
    }
}
开发者ID:ryanspeng,项目名称:yxim,代码行数:24,代码来源:ImUser.cpp

示例14: CHECK_PB_PARSE_MSG

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);
        }
    }
}
开发者ID:hgl888,项目名称:Server,代码行数:84,代码来源:GroupChat.cpp

示例15: user_name

void CDBServConn::_HandleValidateResponse(CImPduValidateResponse* pPdu)
{
    string user_name(pPdu->GetUserName(), pPdu->GetUserNameLen());
	uint32_t result = pPdu->GetResult();
    CDbAttachData attach_data(pPdu->GetAttachData(), pPdu->GetAttachLen());
	log("HandleValidateResp, user_name=%s, result=%d\n", user_name.c_str(), result);

    CImUser* pImUser = CImUserManager::GetInstance()->GetImUserByName(user_name);
	CMsgConn* pMsgConn = NULL;
	if (!pImUser) {
		// can not find the client connection,
		// maybe the client is closed before the DB response arrived
		// do nothing
		log("ImUser for user_name=%s not exist\n", user_name.c_str());
		return;
	} else {
        pMsgConn = pImUser->GetUnValidateMsgConn(attach_data.GetHandle());
		if (!pMsgConn || pMsgConn->IsOpen()) {
			log("no such connection or is validated, user_name=%s\n", user_name.c_str());
			return;
		}
	}

	if (result != 0) {
		result = REFUSE_REASON_DB_VALIDATE_FAILED;
	}
    
	// validate OK, set client validate past, and send FriendListRequest to db storage server
	// else close the client connection
	if (result == 0) {
        user_info_t* user = pPdu->GetUserInfo();
        pImUser->SetUser(user);
        pImUser->SetValidated();
        
        uint32_t user_id = user->user_id;
        CImUserManager::GetInstance()->AddImUserById(user_id, pImUser);
        pImUser->KickOutSameClientType(pMsgConn->GetClientType(), pMsgConn);
        
        CRouteServConn* pRouteConn = get_route_serv_conn();
        if (pRouteConn) {
            CImPduServerKickUser kickPdu(user_id, pMsgConn->GetClientType(), KICK_REASON_DUPLICATE_USER);
            pRouteConn->SendPdu(&kickPdu);
        }
        
        string token = create_uuid();
        log("user_name: %s, uid: %d, token:%s\n", user_name.c_str(), user->user_id, token.c_str());
        pMsgConn->SetToken(token);
        pMsgConn->SetOpen();
        pMsgConn->SendUserActionLog(USER_ACTION_TYPE_LOGIN);
        pMsgConn->SendUserStatusUpdate(USER_STATUS_ONLINE);
        pImUser->ValidateMsgConn(token, pMsgConn);

        CImPduLoginResponse pduLR(result, pImUser->GetIMOnlineStatus(), user, (char*)token.c_str());
        pduLR.SetReserved(pPdu->GetReserved());
        pMsgConn->SendPdu(&pduLR);
	} else {
        CImPduLoginResponse pduLR(result);
        pduLR.SetReserved(pPdu->GetReserved());
        pMsgConn->SendPdu(&pduLR);
        //pMsgConn->Close();
	}
}
开发者ID:3x032,项目名称:TTServer,代码行数:62,代码来源:DBServConn.cpp


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