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


C++ CImPdu::SetServiceId方法代码示例

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


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

示例1: getNormalGroupList

 /**
  *  获取正式群列表
  *
  *  @param pPdu      收到的packet包指针
  *  @param conn_uuid 该包过来的socket 描述符
  */
 void getNormalGroupList(CImPdu* pPdu, uint32_t conn_uuid)
 {
     IM::Group::IMNormalGroupListReq msg;
     IM::Group::IMNormalGroupListRsp msgResp;
     if(msg.ParseFromArray(pPdu->GetBodyData(), pPdu->GetBodyLength()))
     {
         CImPdu* pPduRes = new CImPdu;
         
         uint32_t nUserId = msg.user_id();
         
         list<IM::BaseDefine::GroupVersionInfo> lsGroup;
         CGroupModel::getInstance()->getUserGroup(nUserId, lsGroup, IM::BaseDefine::GROUP_TYPE_NORMAL);
         msgResp.set_user_id(nUserId);
         for(auto it=lsGroup.begin(); it!=lsGroup.end(); ++it)
         {
             IM::BaseDefine::GroupVersionInfo* pGroupVersion = msgResp.add_group_version_list();
             pGroupVersion->set_group_id(it->group_id());
             pGroupVersion->set_version(it->version());
         }
         
         log("getNormalGroupList. userId=%u, count=%d", nUserId, msgResp.group_version_list_size());
         
         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_NORMAL_LIST_RESPONSE);
         CProxyConn::AddResponsePdu(conn_uuid, pPduRes);
     }
     else
     {
         log("parse pb failed");
     }
 }
开发者ID:hgl888,项目名称:Server,代码行数:40,代码来源:GroupAction.cpp

示例2: OnTimer

void CLoginConn::OnTimer(uint64_t curr_tick)
{
	log("enter[%s]", __FUNCTION__);

	if (m_conn_type == LOGIN_CONN_TYPE_CLIENT) {
		if (curr_tick > m_last_recv_tick + CLIENT_TIMEOUT) {
			Close();//超过2min则断开,指的是客户端的短连接2min中内没有新的数据到达,就断开???
		}
	} else {
		if (curr_tick > m_last_send_tick + SERVER_HEARTBEAT_INTERVAL) {//每隔5s就给msg_server发送一个心跳包
            IM::Other::IMHeartBeat msg;
            CImPdu pdu;
            pdu.SetPBMsg(&msg);
            pdu.SetServiceId(SID_OTHER);
            pdu.SetCommandId(CID_OTHER_HEARTBEAT);
			log("Send HeartBeat To MsgServer");
			SendPdu(&pdu);
		}

		//30s内没有收到msg-server的数据,则判断MsgServer断开了
		if (curr_tick > m_last_recv_tick + SERVER_TIMEOUT) {
			log("connection to MsgServer timeout ");
			Close();
		}
	}
	log("leave[%s]", __FUNCTION__);

}
开发者ID:jasonxu1015,项目名称:TT_Centos7,代码行数:28,代码来源:LoginConn.cpp

示例3: _HandleStatusNotify

// friend online/off-line notify
void CRouteServConn::_HandleStatusNotify(CImPdu* pPdu)
{
	IM::Buddy::IMUserStatNotify msg;
	CHECK_PB_PARSE_MSG(msg.ParseFromArray(pPdu->GetBodyData(), pPdu->GetBodyLength()));

	IM::BaseDefine::UserStat user_stat = msg.user_stat();

	log("HandleFriendStatusNotify, user_id=%u, status=%u ", user_stat.user_id(), user_stat.status());

	// send friend online message to client
	//CImUserManager::GetInstance()->BroadcastPdu(pPdu, CLIENT_TYPE_FLAG_PC);

	//send to db
	CDBServConn* pDBConn = get_db_serv_conn();
	//CImUser* pImUser = CImUserManager::GetInstance()->GetImUserById( user_stat.user_id());
	if(pDBConn) //pImUser &&
	{
		IM::Server::IMGetFriendsidReq msgReq;
		msgReq.set_user_id(user_stat.user_id());

		CImPdu dbPdu;

		//CDbAttachData dbAttachData(pPdu->GetBodyData(), pPdu->GetBodyLength());
		//msgReq.set_attach_data(dbAttachData.GetBuffer(), dbAttachData.GetLength());
		msgReq.set_attach_data(pPdu->GetBodyData(), pPdu->GetBodyLength());

		dbPdu.SetPBMsg( &msgReq);
		dbPdu.SetServiceId(DFFX_SID_OTHER);
		dbPdu.SetCommandId(DFFX_CID_OTHER_GETFRIENDSID_REQ);
		dbPdu.SetSeqNum(pPdu->GetSeqNum());

		pDBConn->SendPdu( &dbPdu);
	}
}
开发者ID:hlyces,项目名称:teamtalk_TT,代码行数:35,代码来源:RouteServConn.cpp

示例4: HandleClientGroupChangeMemberRequest

void CGroupChat::HandleClientGroupChangeMemberRequest(CImPdu* pPdu, CMsgConn* pFromConn)
{
    IM::Group::IMGroupChangeMemberReq msg;
    CHECK_PB_PARSE_MSG(msg.ParseFromArray(pPdu->GetBodyData(), pPdu->GetBodyLength()));

	uint32_t change_type = msg.change_type();
	uint32_t req_user_id = pFromConn->GetUserId();
	uint32_t group_id = msg.group_id();
	uint32_t user_cnt = msg.member_id_list_size();
	log("HandleClientChangeMemberReq, change_type=%u, req_id=%u, group_id=%u, user_cnt=%u ",
			change_type, req_user_id, group_id, 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::IMGroupChangeMemberRsp msg2;
        msg2.set_user_id(req_user_id);
        msg2.set_change_type((IM::BaseDefine::GroupModifyType)change_type);
        msg2.set_result_code(1);
        msg2.set_group_id(group_id);
        CImPdu pdu;
        pdu.SetPBMsg(&msg2);
        pdu.SetServiceId(SID_GROUP);
        pdu.SetCommandId(CID_GROUP_CHANGE_MEMBER_RESPONSE);
		pdu.SetSeqNum(pPdu->GetSeqNum());
		pFromConn->SendPdu(&pdu);
	}
}
开发者ID:hgl888,项目名称:Server,代码行数:35,代码来源:GroupChat.cpp

示例5: HandleGroupMessageBroadcast

void CGroupChat::HandleGroupMessageBroadcast(CImPdu *pPdu)
{
    IM::Message::IMMsgData msg;
    CHECK_PB_PARSE_MSG(msg.ParseFromArray(pPdu->GetBodyData(), pPdu->GetBodyLength()));

    uint32_t from_user_id = msg.from_user_id();
    uint32_t to_group_id = msg.to_session_id();
    string msg_data = msg.msg_data();
    uint32_t msg_id = msg.msg_id();
    log("HandleGroupMessageBroadcast, %u->%u, msg id=%u. ", from_user_id, to_group_id, msg_id);
    
    // 服务器没有群的信息,向DB服务器请求群信息,并带上消息作为附件,返回时在发送该消息给其他群成员
    //IM::BaseDefine::GroupVersionInfo group_version_info;
    CPduAttachData pduAttachData(ATTACH_TYPE_HANDLE_AND_PDU, 0,
                                 pPdu->GetBodyLength(), pPdu->GetBodyData());
    
    IM::Group::IMGroupInfoListReq msg2;
    msg2.set_user_id(from_user_id);
    IM::BaseDefine::GroupVersionInfo* group_version_info = msg2.add_group_version_list();
    group_version_info->set_group_id(to_group_id);
    group_version_info->set_version(0);
    msg2.set_attach_data(pduAttachData.GetBuffer(), pduAttachData.GetLength());
    CImPdu pdu;
    pdu.SetPBMsg(&msg2);
    pdu.SetServiceId(SID_GROUP);
    pdu.SetCommandId(CID_GROUP_INFO_REQUEST);
    CDBServConn* pDbConn = get_db_serv_conn();
    if(pDbConn)
    {
        pDbConn->SendPdu(&pdu);
    }
}
开发者ID:hgl888,项目名称:Server,代码行数:32,代码来源:GroupChat.cpp

示例6: HandleClientGroupShieldGroupRequest

void CGroupChat::HandleClientGroupShieldGroupRequest(CImPdu *pPdu, CMsgConn *pFromConn)
{
    IM::Group::IMGroupShieldReq msg;
    CHECK_PB_PARSE_MSG(msg.ParseFromArray(pPdu->GetBodyData(), pPdu->GetBodyLength()));
    
    uint32_t shield_status = msg.shield_status();
    uint32_t group_id = msg.group_id();
    uint32_t user_id = pFromConn->GetUserId();
    log("HandleClientGroupShieldGroupRequest, user_id: %u, group_id: %u, shield_status: %u. ",
        user_id, group_id, shield_status);
    
    CDBServConn* pDbConn = get_db_serv_conn();
	if (pDbConn) {
        CDbAttachData attach_data(ATTACH_TYPE_HANDLE, pFromConn->GetHandle(), 0);
        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::IMGroupShieldRsp msg2;
        msg2.set_user_id(user_id);
        msg2.set_result_code(1);
        CImPdu pdu;
        pdu.SetPBMsg(&msg2);
        pdu.SetServiceId(SID_GROUP);
        pdu.SetCommandId(CID_GROUP_SHIELD_GROUP_RESPONSE);
		pdu.SetSeqNum(pPdu->GetSeqNum());
		pFromConn->SendPdu(&pdu);
	}
}
开发者ID:hgl888,项目名称:Server,代码行数:32,代码来源:GroupChat.cpp

示例7: HandleClientGroupInfoRequest

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

示例8: HandleGroupGetShieldByGroupResponse

void CGroupChat::HandleGroupGetShieldByGroupResponse(CImPdu *pPdu)
{
    IM::Server::IMGroupGetShieldRsp msg;
    CHECK_PB_PARSE_MSG(msg.ParseFromArray(pPdu->GetBodyData(), pPdu->GetBodyLength()));

    uint32_t shield_status_list_cnt = msg.shield_status_list_size();
    
    log("HandleGroupGetShieldByGroupResponse, shield_status_list_cnt: %u. ",
        shield_status_list_cnt);
    
    IM::Server::IMGetDeviceTokenReq msg2;
    msg2.set_attach_data((uchar_t*)msg.attach_data().c_str(), msg.attach_data().length());
    for (uint32_t i = 0; i < shield_status_list_cnt; i++)
    {
        IM::BaseDefine::ShieldStatus shield_status = msg.shield_status_list(i);
        if (shield_status.shield_status() == 0)
        {
            msg2.add_user_id(shield_status.user_id());
        }
        else
        {
            log("user_id: %u shield group, group id: %u. ", shield_status.user_id(), shield_status.group_id());
        }
    }
    CImPdu pdu;
    pdu.SetPBMsg(&msg2);
    pdu.SetServiceId(SID_OTHER);
    pdu.SetCommandId(CID_OTHER_GET_DEVICE_TOKEN_REQ);
    CDBServConn* pDbConn = get_db_serv_conn();
    if (pDbConn) {
        pDbConn->SendPdu(&pdu);
    }
}
开发者ID:hgl888,项目名称:Server,代码行数:33,代码来源:GroupChat.cpp

示例9: createGroup

 /**
  *  创建群组
  *
  *  @param pPdu      收到的packet包指针
  *  @param conn_uuid 该包过来的socket 描述符
  */
 void createGroup(CImPdu* pPdu, uint32_t conn_uuid)
 {
     IM::Group::IMGroupCreateReq msg;
     IM::Group::IMGroupCreateRsp msgResp;
     if(msg.ParseFromArray(pPdu->GetBodyData(), pPdu->GetBodyLength()))
     {
         CImPdu* pPduRes = new CImPdu;
         
         uint32_t nUserId = msg.user_id();
         string strGroupName = msg.group_name();
         IM::BaseDefine::GroupType nGroupType = msg.group_type();
         if(IM::BaseDefine::GroupType_IsValid(nGroupType))
         {
             string strGroupAvatar = msg.group_avatar();
             set<uint32_t> setMember;
             uint32_t nMemberCnt = msg.member_id_list_size();
             for(uint32_t i=0; i<nMemberCnt; ++i)
             {
                 uint32_t nUserId = msg.member_id_list(i);
                 setMember.insert(nUserId);
             }
             log("createGroup.%d create %s, userCnt=%u", nUserId, strGroupName.c_str(), setMember.size());
             
             uint32_t nGroupId = CGroupModel::getInstance()->createGroup(nUserId, strGroupName, strGroupAvatar, nGroupType, setMember);
             msgResp.set_user_id(nUserId);
             msgResp.set_group_name(strGroupName);
             for(auto it=setMember.begin(); it!=setMember.end();++it)
             {
                 msgResp.add_user_id_list(*it);
             }
             if(nGroupId != INVALID_VALUE)
             {
                 msgResp.set_result_code(0);
                 msgResp.set_group_id(nGroupId);
             }
             else
             {
                 msgResp.set_result_code(1);
             }
             
             
             log("createGroup.%d create %s, userCnt=%u, result:%d", nUserId, strGroupName.c_str(), setMember.size(), 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_CREATE_RESPONSE);
             CProxyConn::AddResponsePdu(conn_uuid, pPduRes);
         }
         else
         {
             log("invalid group type.userId=%u, groupType=%u, groupName=%s", nUserId, nGroupType, strGroupName.c_str());
         }
     }
     else
     {
         log("parse pb failed");
     }
 }
开发者ID:hgl888,项目名称:Server,代码行数:66,代码来源:GroupAction.cpp

示例10: _HandlePCLoginStatusNotify

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

示例11: OnConfirm

void CRouteServConn::OnConfirm()
{
	log("connect to route server success ");
	m_bOpen = true;
	m_connect_time = get_tick_count();
	g_route_server_list[m_serv_idx].reconnect_cnt = MIN_RECONNECT_CNT / 2;

	if (!g_master_rs_conn) {
		update_master_route_serv_conn();
	}

	list<user_stat_t> online_user_list;
    CImUserManager::GetInstance()->GetOnlineUserInfo(&online_user_list);
    IM::Server::IMOnlineUserInfo msg;
    for (list<user_stat_t>::iterator it = online_user_list.begin(); it != online_user_list.end(); it++) {
        user_stat_t user_stat = *it;
        IM::BaseDefine::ServerUserStat* server_user_stat = msg.add_user_stat_list();
        server_user_stat->set_user_id(user_stat.user_id);
        server_user_stat->set_status((::IM::BaseDefine::UserStatType)user_stat.status);
        server_user_stat->set_client_type((::IM::BaseDefine::ClientType)user_stat.client_type);

    }
    CImPdu pdu;
    pdu.SetPBMsg(&msg);
    pdu.SetServiceId(SID_OTHER);
    pdu.SetCommandId(CID_OTHER_ONLINE_USER_INFO);
	SendPdu(&pdu);
}
开发者ID:narychen,项目名称:eggie,代码行数:28,代码来源:RouteServConn.cpp

示例12: update_master_route_serv_conn

void update_master_route_serv_conn()
{
	uint64_t oldest_connect_time = (uint64_t)-1;
// 	CRouteServConn* pOldestConn = NULL;
	shared_ptr<CRouteServConn> pOldestConn;

// 	CRouteServConn* pConn = NULL;
    shared_ptr<CRouteServConn> pConn;

	for (uint32_t i = 0; i < g_route_server_count; i++) {
		pConn = g_route_server_list[i].serv_conn;
		if (pConn && pConn->IsOpen() && (pConn->GetConnectTime() < oldest_connect_time) ){
			pOldestConn = pConn;
			oldest_connect_time = pConn->GetConnectTime();
		}
	}

	g_master_rs_conn =  pOldestConn;

	if (g_master_rs_conn) {
        IM::Server::IMRoleSet msg;
        msg.set_master(1);
        CImPdu pdu;
        pdu.SetPBMsg(&msg);
        pdu.SetServiceId(SID_OTHER);
        pdu.SetCommandId(CID_OTHER_ROLE_SET);
		g_master_rs_conn->SendPdu(&pdu);
	}
}
开发者ID:narychen,项目名称:eggie,代码行数:29,代码来源:RouteServConn.cpp

示例13: HandleClientGroupNormalRequest

void CGroupChat::HandleClientGroupNormalRequest(CImPdu* pPdu, CMsgConn* pFromConn)
{
    IM::Group::IMNormalGroupListReq msg;
    CHECK_PB_PARSE_MSG(msg.ParseFromArray(pPdu->GetBodyData(), pPdu->GetBodyLength()));
    uint32_t user_id = pFromConn->GetUserId();
    log("HandleClientGroupNormalRequest, user_id=%u. ", user_id);
    CDbAttachData attach_data(ATTACH_TYPE_HANDLE, pFromConn->GetHandle(), 0);
    
    CDBServConn* pDBConn = get_db_serv_conn();
    if (pDBConn)
    {
        msg.set_user_id(user_id);
        msg.set_attach_data((uchar_t*)attach_data.GetBuffer(), attach_data.GetLength());
        pPdu->SetPBMsg(&msg);
        pDBConn->SendPdu(pPdu);
    }
    else
    {
        log("no db connection. ");
        IM::Group::IMNormalGroupListRsp msg2;
        msg.set_user_id(user_id);
        CImPdu pdu;
        pdu.SetPBMsg(&msg2);
        pdu.SetServiceId(SID_GROUP);
        pdu.SetCommandId(CID_GROUP_NORMAL_LIST_RESPONSE);
        pdu.SetSeqNum(pPdu->GetSeqNum());
        pFromConn->SendPdu(&pdu);
    }
}
开发者ID:hgl888,项目名称:Server,代码行数:29,代码来源:GroupChat.cpp

示例14: modifyMember

 /**
  *  修改群成员,增加或删除
  *
  *  @param pPdu      收到的packet包指针
  *  @param conn_uuid 该包过来的socket 描述符
  */
 void modifyMember(CImPdu* pPdu, uint32_t conn_uuid)
 {
     IM::Group::IMGroupChangeMemberReq msg;
     IM::Group::IMGroupChangeMemberRsp msgResp;
     if(msg.ParseFromArray(pPdu->GetBodyData(), pPdu->GetBodyLength()))
     {
         uint32_t nUserId = msg.user_id();
         uint32_t nGroupId = msg.group_id();
         IM::BaseDefine::GroupModifyType nType = msg.change_type();
         if (IM::BaseDefine::GroupModifyType_IsValid(nType) &&
             CGroupModel::getInstance()->isValidateGroupId(nGroupId)) {
             
             CImPdu* pPduRes = new CImPdu;
             
             uint32_t nCnt = msg.member_id_list_size();
             set<uint32_t> setUserId;
             for(uint32_t i=0; i<nCnt;++i)
             {
                 setUserId.insert(msg.member_id_list(i));
             }
             list<uint32_t> lsCurUserId;
             bool bRet = CGroupModel::getInstance()->modifyGroupMember(nUserId, nGroupId, nType, setUserId, lsCurUserId);
             msgResp.set_user_id(nUserId);
             msgResp.set_group_id(nGroupId);
             msgResp.set_change_type(nType);
             msgResp.set_result_code(bRet?0:1);
             if(bRet)
             {
                 for(auto it=setUserId.begin(); it!=setUserId.end(); ++it)
                 {
                     msgResp.add_chg_user_id_list(*it);
                 }
                 
                 for(auto it=lsCurUserId.begin(); it!=lsCurUserId.end(); ++it)
                 {
                     msgResp.add_cur_user_id_list(*it);
                 }
             }
             log("userId=%u, groupId=%u, result=%u, changeCount:%u, currentCount=%u",nUserId, nGroupId,  bRet?0:1, msgResp.chg_user_id_list_size(), msgResp.cur_user_id_list_size());
             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_CHANGE_MEMBER_RESPONSE);
             CProxyConn::AddResponsePdu(conn_uuid, pPduRes);
         }
         else
         {
             log("invalid groupModifyType or groupId. userId=%u, groupId=%u, groupModifyType=%u", nUserId, nGroupId, nType);
         }
         
     }
     else
     {
         log("parse pb failed");
     }
 }
开发者ID:hgl888,项目名称:Server,代码行数:63,代码来源:GroupAction.cpp

示例15: getGroupInfo

 /**
  *  获取群信息
  *
  *  @param pPdu      收到的packet包指针
  *  @param conn_uuid 该包过来的socket 描述符
  */
 void getGroupInfo(CImPdu* pPdu, uint32_t conn_uuid)
 {
     IM::Group::IMGroupInfoListReq msg;
     IM::Group::IMGroupInfoListRsp msgResp;
     if(msg.ParseFromArray(pPdu->GetBodyData(), pPdu->GetBodyLength()))
     {
         CImPdu* pPduRes = new CImPdu;
         uint32_t nUserId = msg.user_id();
         uint32_t nGroupCnt = msg.group_version_list_size();
         
         map<uint32_t, IM::BaseDefine::GroupVersionInfo> mapGroupId;
         for(uint32_t i=0; i<nGroupCnt; ++i)
         {
             IM::BaseDefine::GroupVersionInfo groupInfo = msg.group_version_list(i);
             if(CGroupModel::getInstance()->isValidateGroupId(groupInfo.group_id()))
             {
                 mapGroupId[groupInfo.group_id()] = groupInfo;
             }
         }
         list<IM::BaseDefine::GroupInfo> lsGroupInfo;
         CGroupModel::getInstance()->getGroupInfo(mapGroupId, lsGroupInfo);
         
         msgResp.set_user_id(nUserId);
         for(auto it=lsGroupInfo.begin(); it!=lsGroupInfo.end(); ++it)
         {
             IM::BaseDefine::GroupInfo* pGroupInfo = msgResp.add_group_info_list();
 //            *pGroupInfo = *it;
             pGroupInfo->set_group_id(it->group_id());
             pGroupInfo->set_version(it->version());
             pGroupInfo->set_group_name(it->group_name());
             pGroupInfo->set_group_avatar(it->group_avatar());
             pGroupInfo->set_group_creator_id(it->group_creator_id());
             pGroupInfo->set_group_type(it->group_type());
             pGroupInfo->set_shield_status(it->shield_status());
             uint32_t nGroupMemberCnt = it->group_member_list_size();
             for (uint32_t i=0; i<nGroupMemberCnt; ++i)
             {
                 uint32_t userId = it->group_member_list(i);
                 pGroupInfo->add_group_member_list(userId);
             }
         }
         
         log("userId=%u, requestCount=%u", nUserId, nGroupCnt);
         
         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_INFO_RESPONSE);
         CProxyConn::AddResponsePdu(conn_uuid, pPduRes);
     }
     else
     {
         log("parse pb failed");
     }
 }
开发者ID:hgl888,项目名称:Server,代码行数:62,代码来源:GroupAction.cpp


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