本文整理汇总了C++中CMsgConn类的典型用法代码示例。如果您正苦于以下问题:C++ CMsgConn类的具体用法?C++ CMsgConn怎么用?C++ CMsgConn使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CMsgConn类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: attach_data
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: CHECK_PB_PARSE_MSG
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: CHECK_PB_PARSE_MSG
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: attach
/////////// 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);
}
}
示例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);
}
示例6: 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);
}
}
}
示例7: CHECK_PB_PARSE_MSG
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);
}
}
}
示例8: 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);
}
}
}
示例9: GetUnValidateMsgConn
CMsgConn* CImUser::GetUnValidateMsgConn(uint32_t handle)
{
for (set<CMsgConn*>::iterator it = m_unvalidate_conn_set.begin(); it != m_unvalidate_conn_set.end(); it++)
{
CMsgConn* pConn = *it;
if (pConn->GetHandle() == handle) {
return pConn;
}
}
return NULL;
}
示例10: msg_serv_callback
// for client connect in
void msg_serv_callback(void* callback_data, uint8_t msg, uint32_t handle, void* pParam)
{
if (msg == NETLIB_MSG_CONNECT)
{
// once new client connect in,relate the socket after accept with CMsgConn,
CMsgConn* pConn = new CMsgConn();
pConn->OnConnect(handle); // add this socket to eventloop
}
else
{
log("!!!error msg: %d ", msg);
}
}
示例11: GetUserConn
user_conn_t CImUser::GetUserConn()
{
uint32_t conn_cnt = 0;
for (map<uint32_t, CMsgConn*>::iterator it = m_conn_map.begin(); it != m_conn_map.end(); it++)
{
CMsgConn* pConn = it->second;
if (pConn->IsOpen()) {
conn_cnt++;
}
}
user_conn_t user_cnt = {m_user_id, conn_cnt};
return user_cnt;
}
示例12: log
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: attach_data
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);
}
}
示例14: log
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);
}
}
示例15: BroadcastData
void CImUser::BroadcastData(void *buff, uint32_t len, CMsgConn* pFromConn)
{
if(!buff)
return;
for (map<uint32_t, CMsgConn*>::iterator it = m_conn_map.begin(); it != m_conn_map.end(); it++)
{
CMsgConn* pConn = it->second;
if(pConn == NULL)
continue;
if (pConn != pFromConn) {
pConn->Send(buff, len);
}
}
}