本文整理汇总了C++中CMsgConn::SendPdu方法的典型用法代码示例。如果您正苦于以下问题:C++ CMsgConn::SendPdu方法的具体用法?C++ CMsgConn::SendPdu怎么用?C++ CMsgConn::SendPdu使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CMsgConn
的用法示例。
在下文中一共展示了CMsgConn::SendPdu方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _HandleFriendListResponse
void CDBServConn::_HandleFriendListResponse(CImPduFriendListResponse* pPdu)
{
uint32_t user_id = pPdu->GetFromUserId();
uint32_t friend_cnt = pPdu->GetFriendCnt();
user_info_t* friend_list = pPdu->GetFriendList();
CDbAttachData attach_data(pPdu->GetAttachData(), pPdu->GetAttachLen());
uint32_t handle = attach_data.GetHandle();
log("HandleFriendListResp, user_id=%d, friend_cnt=%d\n", user_id, friend_cnt);
CMsgConn* pToConn = CImUserManager::GetInstance()->GetMsgConnByHandle(user_id, handle);
if (!pToConn || !pToConn->IsOpen()) {
return;
}
CRouteServConn* pRouteConn = get_route_serv_conn();
if (!pRouteConn) {
CImPduLoginResponse pduLR(REFUSE_REASON_NO_ROUTE_SERVER);
pduLR.SetReserved(pPdu->GetReserved());
pToConn->SendPdu(&pduLR);
pToConn->Close();
return;
}
// transfer from server friend list form to client friend list form (uid->url)
CImPduClientFriendList pduCFL(friend_cnt, friend_list);
pduCFL.SetReserved(pPdu->GetReserved());
pToConn->SendPdu(&pduCFL);
}
示例2: BroadcastClientMsgData
void CImUser::BroadcastClientMsgData(CImPdu* pPdu, uint32_t msg_id, string msg_data, CMsgConn* pFromConn, uint32_t from_id)
{
IM::Message::IMMsgData msg;
CHECK_PB_PARSE_MSG(msg.ParseFromArray(pPdu->GetBodyData(), pPdu->GetBodyLength()));
for (map<uint32_t, CMsgConn*>::iterator it = m_conn_map.begin(); it != m_conn_map.end(); it++)
{
CMsgConn* pConn = it->second;
if (pConn != NULL && pConn != pFromConn) {
if (pConn->GetCryptoFlag() == 1)
{
string tmp_msg_data = msg_data;
if (pConn->EncryptMsgData(tmp_msg_data) == 0)
{
//log("BroadcastClientMsgData, from %u to %u data: %s", from_id, pConn->GetUserId(), tmp_msg_data.c_str()); //debug crypto
msg.set_crypto_flag(1);
msg.set_msg_data(tmp_msg_data);
pPdu->SetPBMsg(&msg);
}
}
pConn->SendPdu(pPdu);
pConn->AddToSendList(msg_id, from_id);
}
}
}
示例3: _HandleUnreadMsgCountResponse
void CDBServConn::_HandleUnreadMsgCountResponse(CImPdu* pPdu)
{
IM::Message::IMUnreadMsgCntRsp msg;
CHECK_PB_PARSE_MSG(msg.ParseFromArray(pPdu->GetBodyData(), pPdu->GetBodyLength()));
uint32_t user_id = msg.user_id();
uint32_t total_cnt = msg.total_cnt();
uint32_t user_unread_cnt = msg.unreadinfo_list_size();
CDbAttachData attach_data((uchar_t*)msg.attach_data().c_str(), msg.attach_data().length());
uint32_t handle = attach_data.GetHandle();
log("HandleUnreadMsgCntResp, userId=%u, total_cnt=%u, user_unread_cnt=%u.", user_id,
total_cnt, user_unread_cnt);
CMsgConn* pMsgConn = CImUserManager::GetInstance()->GetMsgConnByHandle(user_id, handle);
if (pMsgConn && pMsgConn->IsOpen()) {
if (pMsgConn->GetCryptoFlag() == 1)
{
for (int i=0; i < user_unread_cnt; i++)
{
IM::BaseDefine::UnreadInfo* pInfo = msg.mutable_unreadinfo_list(i);
string msg_data = (string)pInfo->latest_msg_data();
pMsgConn->EncryptMsgData(msg_data);
//log("HandleUnreadMsgCntResp, %u data: %s", user_id, msg_data.c_str()); //debug crypto
pInfo->set_latest_msg_data(msg_data);
}
}
msg.clear_attach_data();
pPdu->SetPBMsg(&msg);
pMsgConn->SendPdu(pPdu);
}
}
示例4: _HandleGetMsgByIdResponse
void CDBServConn::_HandleGetMsgByIdResponse(CImPdu *pPdu)
{
IM::Message::IMGetMsgByIdRsp msg;
CHECK_PB_PARSE_MSG(msg.ParseFromArray(pPdu->GetBodyData(), pPdu->GetBodyLength()));
uint32_t user_id = msg.user_id();
uint32_t session_type = msg.session_type();
uint32_t session_id = msg.session_id();
uint32_t msg_cnt = msg.msg_list_size();
CDbAttachData attach_data((uchar_t*)msg.attach_data().c_str(), msg.attach_data().length());
uint32_t handle = attach_data.GetHandle();
log("HandleGetMsgByIdResponse, userId=%u, session_type=%u, opposite_user_id=%u, cnt=%u.", user_id, session_type, session_id, msg_cnt);
CMsgConn* pMsgConn = CImUserManager::GetInstance()->GetMsgConnByHandle(user_id, handle);
if (pMsgConn && pMsgConn->IsOpen()) {
if (pMsgConn->GetCryptoFlag() == 1)
{
for (int i=0; i < msg_cnt; i++)
{
IM::BaseDefine::MsgInfo* pMsg = msg.mutable_msg_list(i);
string msg_data = (string)pMsg->msg_data();
pMsgConn->EncryptMsgData(msg_data);
//log("HandleGetMsgByIdRepsone, %u->%u data: %s", user_id, session_id, msg_data.c_str()); //debug crypto
pMsg->set_msg_data(msg_data);
}
}
msg.clear_attach_data();
pPdu->SetPBMsg(&msg);
pMsgConn->SendPdu(pPdu);
}
}
示例5: _HandleRecentSessionResponse
void CDBServConn::_HandleRecentSessionResponse(CImPdu *pPdu)
{
IM::Buddy::IMRecentContactSessionRsp msg;
CHECK_PB_PARSE_MSG(msg.ParseFromArray(pPdu->GetBodyData(), pPdu->GetBodyLength()));
uint32_t user_id = msg.user_id();
uint32_t session_cnt = msg.contact_session_list_size();
CDbAttachData attach_data((uchar_t*)msg.attach_data().c_str(), msg.attach_data().length());
uint32_t handle = attach_data.GetHandle();
log("HandleRecentSessionResponse, userId=%u, session_cnt=%u", user_id, session_cnt);
CMsgConn* pMsgConn = CImUserManager::GetInstance()->GetMsgConnByHandle(user_id, handle);
if (pMsgConn && pMsgConn->IsOpen())
{
if (pMsgConn->GetCryptoFlag() == 1)
{
for (int i=0; i < session_cnt; i++)
{
IM::BaseDefine::ContactSessionInfo* pInfo = msg.mutable_contact_session_list(i);
string msg_data = (string)pInfo->latest_msg_data();
pMsgConn->EncryptMsgData(msg_data);
//log("HandleRecentSessionResponse, %u data: %s", user_id, msg_data.c_str()); //debug crypto
pInfo->set_latest_msg_data(msg_data);
}
}
msg.clear_attach_data();
pPdu->SetPBMsg(&msg);
pMsgConn->SendPdu(pPdu);
}
}
示例6: HandleFileHasOfflineRes
/////////// for server
void CFileHandler::HandleFileHasOfflineRes(CImPduFileHasOfflineRes* pPdu)
{
uint32_t req_user_id = pPdu->GetReqUserId();
uint32_t file_cnt = pPdu->GetFileCnt();
offline_file_t* file_list = pPdu->GetFileList();
CDbAttachData attach(pPdu->GetAttachData(), pPdu->GetAttachLen());
log("HandleFileHasOfflineRes, req_id=%u, file_cnt=%u\n", req_user_id, file_cnt);
CMsgConn* pConn = CImUserManager::GetInstance()->GetMsgConnByHandle(req_user_id,
attach.GetHandle());
CFileServConn* pFileConn = get_random_file_serv_conn();
const list<ip_addr_t>* ip_list = NULL;
if (pFileConn)
{
ip_list = pFileConn->GetFileServerIPList();
}
else
{
log("HandleFileHasOfflineRes, no file server.\n");
}
if (pConn) {
CImPduClientFileHasOfflineRes pdu(file_cnt, file_list, ip_list);
pdu.SetReserved(pPdu->GetReserved());
pConn->SendPdu(&pdu);
}
}
示例7: _HandleMsgData
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);
}
示例8: BroadcastPduWithOutMobile
void CImUser::BroadcastPduWithOutMobile(CImPdu *pPdu, CMsgConn* pFromConn)
{
for (map<uint32_t, CMsgConn*>::iterator it = m_conn_map.begin(); it != m_conn_map.end(); it++)
{
CMsgConn* pConn = it->second;
if (pConn != pFromConn && CHECK_CLIENT_TYPE_PC(pConn->GetClientType())) {
pConn->SendPdu(pPdu);
}
}
}
示例9: BroadcastPdu
void CImUser::BroadcastPdu(CImPdu* pPdu, CMsgConn* pFromConn)
{
//log("BroadcastPdu: from_id=%u", pFromConn->GetUserId());
for (map<uint32_t, CMsgConn*>::iterator it = m_conn_map.begin(); it != m_conn_map.end(); it++)
{
CMsgConn* pConn = it->second;
if (pConn->GetUserId() != pFromConn->GetUserId()) {
pConn->SendPdu(pPdu);
}
}
}
示例10: HandleGroupChangeMemberResponse
void CGroupChat::HandleGroupChangeMemberResponse(CImPdu* pPdu)
{
IM::Group::IMGroupChangeMemberRsp msg;
CHECK_PB_PARSE_MSG(msg.ParseFromArray(pPdu->GetBodyData(), pPdu->GetBodyLength()));
uint32_t change_type = msg.change_type();
uint32_t user_id = msg.user_id();
uint32_t result = msg.result_code();
uint32_t group_id = msg.group_id();
uint32_t chg_user_cnt = msg.chg_user_id_list_size();
uint32_t cur_user_cnt = msg.cur_user_id_list_size();
log("HandleChangeMemberResp, change_type=%u, req_id=%u, group_id=%u, result=%u, chg_usr_cnt=%u, cur_user_cnt=%u. ",
change_type, user_id, group_id, result, chg_user_cnt, cur_user_cnt);
CDbAttachData attach_data((uchar_t*)msg.attach_data().c_str(), msg.attach_data().length());
CMsgConn* pFromConn = CImUserManager::GetInstance()->GetMsgConnByHandle(user_id,
attach_data.GetHandle());
if (pFromConn) {
msg.clear_attach_data();
pPdu->SetPBMsg(&msg);
pFromConn->SendPdu(pPdu);
}
if (!result) {
IM::Group::IMGroupChangeMemberNotify msg2;
msg2.set_user_id(user_id);
msg2.set_change_type((::IM::BaseDefine::GroupModifyType)change_type);
msg2.set_group_id(group_id);
for (uint32_t i = 0; i < chg_user_cnt; i++) {
msg2.add_chg_user_id_list(msg.chg_user_id_list(i));
}
for (uint32_t i = 0; i < cur_user_cnt; i++) {
msg2.add_cur_user_id_list(msg.cur_user_id_list(i));
}
CImPdu pdu;
pdu.SetPBMsg(&msg2);
pdu.SetServiceId(SID_GROUP);
pdu.SetCommandId(CID_GROUP_CHANGE_MEMBER_NOTIFY);
CRouteServConn* pRouteConn = get_route_serv_conn();
if (pRouteConn) {
pRouteConn->SendPdu(&pdu);
}
for (uint32_t i = 0; i < chg_user_cnt; i++)
{
uint32_t to_user_id = msg.chg_user_id_list(i);
_SendPduToUser(&pdu, to_user_id, pFromConn);
}
for (uint32_t i = 0; i < cur_user_cnt; i++) {
uint32_t to_user_id = msg.cur_user_id_list(i);
_SendPduToUser(&pdu, to_user_id, pFromConn);
}
}
}
示例11: _HandleDBQueryResponse
void CDBServConn::_HandleDBQueryResponse(CImPduDBQueryResponse* pPdu)
{
uint32_t user_id = pPdu->GetUserid();
uint32_t seq_no = pPdu->GetSeqNo();
CDbAttachData attach_data(pPdu->GetAttachData(), pPdu->GetAttachLen());
uint32_t handle = attach_data.GetHandle();
CMsgConn* pMsgConn = CImUserManager::GetInstance()->GetMsgConnByHandle(user_id, handle);
log("HandleDBQueryResp, user_id=%u, seq_no=%u\n", user_id, seq_no);
if (pMsgConn && pMsgConn->IsOpen()) {
CImPduClientDBQueryResponse pdu(seq_no, pPdu->GetResultLen(), pPdu->GetResultData());
pMsgConn->SendPdu(&pdu);
}
}
示例12: _HandleUsersStatusResponse
void CRouteServConn::_HandleUsersStatusResponse(CImPduUsersStatusResponse* pPdu)
{
uint32_t request_id = pPdu->GetRequestId();
uint32_t result_count = pPdu->GetResultCount();
const list<user_stat_t>& result_list = pPdu->GetQueryResult();
log("HandleUsersStatusResp, req_id=%u, query_count=%u\n", request_id, result_count);
CDbAttachData attach_data(pPdu->GetAttachData(), pPdu->GetAttachLen());
uint32_t handle = attach_data.GetHandle();
CMsgConn* pToConn = CImUserManager::GetInstance()->GetMsgConnByHandle(request_id,handle);
if (pToConn) {
CImPduClientUsersStatusResponse pdu(result_list);
pToConn->SendPdu(&pdu);
}
}
示例13: _HandleDepartmentResponse
void CDBServConn::_HandleDepartmentResponse(CImPduDepartmentResponse *pPdu)
{
uint32_t req_user_id = pPdu->GetReqUserId();
uint32_t depart_cnt = pPdu->GetDepartCnt();
department_info_t* depart_list = pPdu->GetDepartList();
log("HandleDepartmentResp, req_user_id=%u, depart_cnt=%u\n", req_user_id, depart_cnt);
CDbAttachData attach_data(pPdu->GetAttachData(), pPdu->GetAttachLen());
uint32_t handle = attach_data.GetHandle();
CMsgConn* pMsgConn = CImUserManager::GetInstance()->GetMsgConnByHandle(req_user_id, handle);
if (pMsgConn && pMsgConn->IsOpen()) {
CImPduClientDepartmentResponse pdu(depart_cnt, depart_list);
pdu.SetReserved(pPdu->GetReserved());
pMsgConn->SendPdu(&pdu);
}
}
示例14: _HandleUserStatusResponse
void CRouteServConn::_HandleUserStatusResponse(CImPduUserStatusResponse* pPdu)
{
uint32_t request_id = pPdu->GetRequestId();
uint32_t query_id = pPdu->GetQueryId();
uint32_t status = pPdu->GetStatus();
CDbAttachData attach_data(pPdu->GetAttachData(), pPdu->GetAttachLen());
uint32_t handle = attach_data.GetHandle();
log("HandleUserStatusResp, req_id=%u, query_id=%u, status=%u\n", request_id, query_id, status);
CMsgConn* pToConn = CImUserManager::GetInstance()->GetMsgConnByHandle(request_id,handle);
if (pToConn) {
char* query_id_url = idtourl(query_id);
CImPduClientUserStatusResponse pdu(query_id_url, status);
pToConn->SendPdu(&pdu);
}
}
示例15: _HandleUnreadMsgCountResponse
void CDBServConn::_HandleUnreadMsgCountResponse(CImPduUnreadMsgCountResponse* pPdu)
{
uint32_t to_user_id = pPdu->GetToUserId();
UserUnreadMsgCnt_t* user_unread_list = pPdu->GetUserUnreadList();
uint32_t user_unread_cnt = pPdu->GetUserUnreadCnt();
CDbAttachData attach_data(pPdu->GetAttachData(), pPdu->GetAttachLen());
uint32_t handle = attach_data.GetHandle();
log("HandleUnreadMsgCntResp, userId=%u, cnt=%u\n", to_user_id, user_unread_cnt);
CMsgConn* pMsgConn = CImUserManager::GetInstance()->GetMsgConnByHandle(to_user_id, handle);
if (pMsgConn && pMsgConn->IsOpen()) {
CImPduClientUnreadMsgCntResponse pdu(user_unread_cnt, user_unread_list);
pdu.SetReserved(pPdu->GetReserved());
pMsgConn->SendPdu(&pdu);
}
}