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


C++ CImPdu类代码示例

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


在下文中一共展示了CImPdu类的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: log

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: CHECK_PB_PARSE_MSG

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

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

示例5: 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

示例6: 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

示例7: log

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

示例8: 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

示例9: 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

示例10: 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

示例11: netlib_recv

void CImConn::OnRead()
{
	for (;;)
	{
		uint32_t free_buf_len = m_in_buf.GetAllocSize() - m_in_buf.GetWriteOffset();
		if (free_buf_len < READ_BUF_SIZE)
			m_in_buf.Extend(READ_BUF_SIZE);

		int ret = netlib_recv(m_handle, m_in_buf.GetBuffer() + m_in_buf.GetWriteOffset(), READ_BUF_SIZE);
		if (ret == 0) {
			log("close on netlib_recv=0");
			OnClose();
			return;
		} else if (ret < 0) {
			if (errno == EAGAIN || errno == EWOULDBLOCK) {
				break;
			} else {
				log("close on error=%d", errno);
				OnClose();
				return;
			}
		}

		m_recv_bytes += ret;
		m_in_buf.IncWriteOffset(ret);

		m_last_recv_tick = get_tick_count();
	}

    CImPdu* pPdu = NULL;
	try
    {
		while ( ( pPdu = CImPdu::ReadPdu(m_in_buf.GetBuffer(), m_in_buf.GetWriteOffset()) ) )
		{
            uint32_t pdu_len = pPdu->GetLength();
            
			HandlePdu(pPdu);

			m_in_buf.Read(NULL, pdu_len);
			delete pPdu;
            pPdu = NULL;
//			++g_recv_pkt_cnt;
		}
	} catch (CPduException& ex) {
		log("!!!catch exception, sid=%u, cid=%u, err_code=%u, err_msg=%s, close the connection ",
				ex.GetServiceId(), ex.GetCommandId(), ex.GetErrorCode(), ex.GetErrorMsg());
        if (pPdu) {
            delete pPdu;
            pPdu = NULL;
        }
        OnClose();
	}
}
开发者ID:narychen,项目名称:eggie,代码行数:53,代码来源:imconn.cpp

示例12: getChangedUser

 void getChangedUser(CImPdu* pPdu, uint32_t conn_uuid)
 {
     IM::Buddy::IMAllUserReq msg;
     IM::Buddy::IMAllUserRsp msgResp;
     if(msg.ParseFromArray(pPdu->GetBodyData(), pPdu->GetBodyLength()))
     {
         CImPdu* pPduRes = new CImPdu;
         
         uint32_t nReqId = msg.user_id();
         uint32_t nLastTime = msg.latest_update_time();
         uint32_t nLastUpdate = CSyncCenter::getInstance()->getLastUpdate();
         
         list<IM::BaseDefine::UserInfo> lsUsers;
         if( nLastUpdate > nLastTime)
         {
             list<uint32_t> lsIds;
             CUserModel::getInstance()->getChangedId(nLastTime, lsIds);
             CUserModel::getInstance()->getUsers(lsIds, lsUsers);
         }
         msgResp.set_user_id(nReqId);
         msgResp.set_latest_update_time(nLastTime);
         for (list<IM::BaseDefine::UserInfo>::iterator it=lsUsers.begin();
              it!=lsUsers.end(); ++it)
         {
             IM::BaseDefine::UserInfo* pUser = msgResp.add_user_list();
             //            *pUser = *it;
             pUser->set_user_id(it->user_id());
             pUser->set_user_gender(it->user_gender());
             pUser->set_user_nick_name(it->user_nick_name());
             pUser->set_avatar_url(it->avatar_url());
             pUser->set_sign_info(it->sign_info());
             pUser->set_department_id(it->department_id());
             pUser->set_email(it->email());
             pUser->set_user_real_name(it->user_real_name());
             pUser->set_user_tel(it->user_tel());
             pUser->set_user_domain(it->user_domain());
             pUser->set_status(it->status());
         }
         log("userId=%u,nLastUpdate=%u, last_time=%u, userCnt=%u", nReqId,nLastUpdate,
             nLastTime, msgResp.user_list_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_ALL_USER_RESPONSE);
         CProxyConn::AddResponsePdu(conn_uuid, pPduRes);
     }
     else
     {
         log("parse pb failed");
     }
 }
开发者ID:hgl888,项目名称:Server,代码行数:52,代码来源:UserAction.cpp

示例13: getUnreadMsgCnt

uint32_t ClientConn::getUnreadMsgCnt(uint32_t nUserId)
{
    CImPdu cPdu;
    IM::Message::IMUnreadMsgCntReq msg;
    msg.set_user_id(nUserId);
    cPdu.SetPBMsg(&msg);
    cPdu.SetServiceId(IM::BaseDefine::SID_MSG);
    cPdu.SetCommandId(IM::BaseDefine::CID_MSG_UNREAD_CNT_REQUEST);
    uint32_t nSeqNo = m_pSeqAlloctor->getSeq(ALLOCTOR_PACKET);
    cPdu.SetSeqNum(nSeqNo);
    SendPdu(&cPdu);
    return nSeqNo;
}
开发者ID:vonway,项目名称:teamtalk-server,代码行数:13,代码来源:ClientConn.cpp

示例14: netlib_recv

void CImConn::OnRead()
{
	for (;;)
	{
		uint32_t free_buf_len = m_in_buf.GetAllocSize() - m_in_buf.GetWriteOffset();
		if (free_buf_len < READ_BUF_SIZE)
			m_in_buf.Extend(READ_BUF_SIZE);

		int ret = netlib_recv(m_handle, m_in_buf.GetBuffer() + m_in_buf.GetWriteOffset(), READ_BUF_SIZE);
		if (ret <= 0)
			break;

		m_recv_bytes += ret;
		m_in_buf.IncWriteOffset(ret);

		m_last_recv_tick = get_tick_count();
	}

	if (m_policy_conn) {
		return;
	}

	// no received data is read by ReadPdu(), check if this is a flash security policy request
	if (m_recv_bytes == m_in_buf.GetWriteOffset()) {
		if ( (m_in_buf.GetBuffer()[0] == '<') && (g_policy_content != NULL) ) {
			log("policy request, handle=%d\n", m_handle);
			m_policy_conn = true;
			Send(g_policy_content, g_policy_len);
			return;
		}
	}

	try {
		CImPdu* pPdu = NULL;
		while ( ( pPdu = CImPdu::ReadPdu(m_in_buf.GetBuffer(), m_in_buf.GetWriteOffset()) ) )
		{
			uint32_t pdu_len = pPdu->GetLength();

			HandlePdu(pPdu);

			m_in_buf.Read(NULL, pdu_len);
			delete pPdu;

			++g_recv_pkt_cnt;
		}
	} catch (CPduException& ex) {
		log("!!!catch exception, sid=%u, cid=%u, err_code=%u, err_msg=%s, close the connection\n",
				ex.GetModuleId(), ex.GetCommandId(), ex.GetErrorCode(), ex.GetErrorMsg());
		OnClose();
	}
}
开发者ID:343829084,项目名称:IMServer,代码行数:51,代码来源:imconn.cpp

示例15: getRecentSession

uint32_t ClientConn::getRecentSession(uint32_t nUserId, uint32_t nLastTime)
{
    CImPdu cPdu;
    IM::Buddy::IMRecentContactSessionReq msg;
    msg.set_user_id(nUserId);
    msg.set_latest_update_time(nLastTime);
    cPdu.SetPBMsg(&msg);
    cPdu.SetServiceId(IM::BaseDefine::SID_BUDDY_LIST);
    cPdu.SetCommandId(IM::BaseDefine::CID_BUDDY_LIST_RECENT_CONTACT_SESSION_REQUEST);
    uint32_t nSeqNo = m_pSeqAlloctor->getSeq(ALLOCTOR_PACKET);
    cPdu.SetSeqNum(nSeqNo);
    SendPdu(&cPdu);
    return nSeqNo;
}
开发者ID:vonway,项目名称:teamtalk-server,代码行数:14,代码来源:ClientConn.cpp


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