本文整理汇总了C++中CMsgConn::GetOnlineStatus方法的典型用法代码示例。如果您正苦于以下问题:C++ CMsgConn::GetOnlineStatus方法的具体用法?C++ CMsgConn::GetOnlineStatus怎么用?C++ CMsgConn::GetOnlineStatus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CMsgConn
的用法示例。
在下文中一共展示了CMsgConn::GetOnlineStatus方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
}
}
}
}
示例2: _HandleValidateResponse
void CDBServConn::_HandleValidateResponse(CImPdu* pPdu)
{
IM::Server::IMValidateRsp msg;
CHECK_PB_PARSE_MSG(msg.ParseFromArray(pPdu->GetBodyData(), pPdu->GetBodyLength()));
string login_name = msg.user_name();
uint32_t result = msg.result_code();
string result_string = msg.result_string();
CDbAttachData attach_data((uchar_t*)msg.attach_data().c_str(), msg.attach_data().length());
log("HandleValidateResp, user_name=%s, result=%d", login_name.c_str(), result);
CImUser* pImUser = CImUserManager::GetInstance()->GetImUserByLoginName(login_name);
CMsgConn* pMsgConn = NULL;
if (!pImUser) {
log("ImUser for user_name=%s not exist", login_name.c_str());
return;
} else {
pMsgConn = pImUser->GetUnValidateMsgConn(attach_data.GetHandle());
if (!pMsgConn || pMsgConn->IsOpen()) {
log("no such conn is validated, user_name=%s", login_name.c_str());
return;
}
}
if (result != 0) {
result = IM::BaseDefine::REFUSE_REASON_DB_VALIDATE_FAILED;
}
if (result == 0)
{
IM::BaseDefine::UserInfo user_info = msg.user_info();
uint32_t user_id = user_info.user_id();
CImUser* pUser = CImUserManager::GetInstance()->GetImUserById(user_id);
if (pUser)
{
pUser->AddUnValidateMsgConn(pMsgConn);
pImUser->DelUnValidateMsgConn(pMsgConn);
if (pImUser->IsMsgConnEmpty())
{
CImUserManager::GetInstance()->RemoveImUserByLoginName(login_name);
delete pImUser;
}
}
else
{
pUser = pImUser;
}
pUser->SetUserId(user_id);
pUser->SetNickName(user_info.user_nick_name());
pUser->SetValidated(); //帐号验证通过
CImUserManager::GetInstance()->AddImUserById(user_id, pUser);
pUser->KickOutSameClientType(pMsgConn->GetClientType(), IM::BaseDefine::KICK_REASON_DUPLICATE_USER, pMsgConn);
CRouteServConn* pRouteConn = get_route_serv_conn();
if (pRouteConn)
{
IM::Server::IMServerKickUser msg2;
msg2.set_user_id(user_id);
msg2.set_client_type((::IM::BaseDefine::ClientType)pMsgConn->GetClientType());
msg2.set_reason(1); //1是什么鬼
pRouteConn->SendPdu(SID_OTHER, CID_OTHER_SERVER_KICK_USER, msg2);
}
log("user_name: %s, uid: %d", login_name.c_str(), user_id);
pMsgConn->SetUserId(user_id);
pMsgConn->SetOpen();
pMsgConn->SendUserStatusUpdate(IM::BaseDefine::USER_STATUS_ONLINE);
pUser->ValidateMsgConn(pMsgConn->GetHandle(), pMsgConn);
IM::Login::IMLoginRes msg3;
msg3.set_server_time(time(NULL));
msg3.set_result_code(IM::BaseDefine::REFUSE_REASON_NONE);
msg3.set_result_string(result_string);
msg3.set_online_status((IM::BaseDefine::UserStatType)pMsgConn->GetOnlineStatus());
IM::BaseDefine::UserInfo* user_info_tmp = msg3.mutable_user_info();
user_info_tmp->set_user_id(user_info.user_id());
user_info_tmp->set_user_gender(user_info.user_gender());
user_info_tmp->set_user_nick_name(user_info.user_nick_name());
user_info_tmp->set_avatar_url(user_info.avatar_url());
user_info_tmp->set_sign_info(user_info.sign_info());
user_info_tmp->set_department_id(user_info.department_id());
user_info_tmp->set_email(user_info.email());
user_info_tmp->set_user_real_name(user_info.user_real_name());
user_info_tmp->set_user_tel(user_info.user_tel());
user_info_tmp->set_user_domain(user_info.user_domain());
user_info_tmp->set_status(user_info.status());
pMsgConn->SendPdu(SID_LOGIN, CID_LOGIN_RES_USERLOGIN, msg3);
}
else
{
IM::Login::IMLoginRes msg4;
msg4.set_server_time(time(NULL));
msg4.set_result_code((IM::BaseDefine::ResultType)result);
msg4.set_result_string(result_string);
pMsgConn->SendPdu(SID_LOGIN, CID_LOGIN_RES_USERLOGIN, msg4);
//.........这里部分代码省略.........
示例3: _HandleValidateResponse
//.........这里部分代码省略.........
ios_total_users++;
break;
case IM::BaseDefine::CLIENT_TYPE_WEB:
web_total_users++;
break;
}
if (result == 0)
{
IM::BaseDefine::UserInfo user_info = msg.user_info();
uint32_t user_id = user_info.user_id();
CImUser* pUser = CImUserManager::GetInstance()->GetImUserById(user_id);
if (pUser)
{
log("_HandleValidateResponse, get user %u(%p) key=%s %p", user_id, pUser, strKey.c_str(), pMsgConn);
pUser->AddUnValidateMsgConn(pMsgConn);
pImUser->DelUnValidateMsgConn(pMsgConn);
if (pImUser->IsMsgConnEmpty())
{
CImUserManager::GetInstance()->RemoveImUserByLoginName(login_name);
delete pImUser;
}
}
else
{
pUser = pImUser;
log("_HandleValidateResponse, use login user %u(%p) key=%s %p", user_id, pUser, strKey.c_str(), pMsgConn);
}
pUser->SetUserId(user_id);
pUser->SetNickName(user_info.user_nick_name());
pUser->SetValidated();
CImUserManager::GetInstance()->AddImUserById(user_id, pUser);
log("user_name: %s, uid: %d(%p)", login_name.c_str(), user_id, pMsgConn);
pMsgConn->SetKey(strKey);
pMsgConn->SetUserId(user_id);
pMsgConn->SetOpen();
pMsgConn->SendUserStatusUpdate(IM::BaseDefine::USER_STATUS_ONLINE);
CRouteServConn* pRouteConn = get_route_serv_conn();
if (pRouteConn) {
IM::Server::IMServerKickUser msg2;
msg2.set_user_id(user_id);
msg2.set_client_type((::IM::BaseDefine::ClientType)pMsgConn->GetClientType());
msg2.set_reason(1);
CImPdu pdu;
pdu.SetPBMsg(&msg2);
pdu.SetServiceId(SID_OTHER);
pdu.SetCommandId(CID_OTHER_SERVER_KICK_USER);
pRouteConn->SendPdu(&pdu);
}
pUser->ValidateMsgConn(pMsgConn->GetHandle(), pMsgConn);
//pUser->KickOutSameClientType(pMsgConn->GetClientType(), IM::BaseDefine::KICK_REASON_DUPLICATE_USER, user_id);
pUser->KickOutSameClientType(pMsgConn->GetClientType(), IM::BaseDefine::KICK_REASON_DUPLICATE_USER, pMsgConn);
IM::Login::IMLoginRes msg3;
msg3.set_server_time(time(NULL));
msg3.set_result_code(IM::BaseDefine::REFUSE_REASON_NONE);
msg3.set_result_string(result_string);
msg3.set_online_status((IM::BaseDefine::UserStatType)pMsgConn->GetOnlineStatus());
msg3.set_client_key(strKey);
IM::BaseDefine::UserInfo* user_info_tmp = msg3.mutable_user_info();
user_info_tmp->set_user_id(user_info.user_id());
user_info_tmp->set_user_gender(user_info.user_gender());
user_info_tmp->set_user_nick_name(user_info.user_nick_name());
user_info_tmp->set_avatar_url(user_info.avatar_url());
user_info_tmp->set_sign_info(user_info.sign_info());
user_info_tmp->set_department_id(user_info.department_id());
user_info_tmp->set_email(user_info.email());
user_info_tmp->set_user_real_name(user_info.user_real_name());
user_info_tmp->set_user_tel(user_info.user_tel());
user_info_tmp->set_user_domain(user_info.user_domain());
user_info_tmp->set_status(user_info.status());
user_info_tmp->set_user_type(user_info.user_type());
log("id:%u gender:%u nick:%s avatar:%s sign:%s depid:%u email:%s name:%s tel:%s uname:%s status:%u type:%u", user_info.user_id(), user_info.user_gender(), user_info.user_nick_name().c_str(), user_info.avatar_url().c_str(), user_info.sign_info().c_str(), user_info.department_id(), user_info.email().c_str(), user_info.user_real_name().c_str(), user_info.user_tel().c_str(), user_info.user_domain().c_str(), user_info.status(), user_info.user_type());
CImPdu pdu2;
pdu2.SetPBMsg(&msg3);
pdu2.SetServiceId(SID_LOGIN);
pdu2.SetCommandId(CID_LOGIN_RES_USERLOGIN);
pdu2.SetSeqNum(pPdu->GetSeqNum());
pMsgConn->SendPdu(&pdu2);
}
else
{
fail_users++;
IM::Login::IMLoginRes msg4;
msg4.set_server_time(time(NULL));
msg4.set_result_code((IM::BaseDefine::ResultType)result);
msg4.set_result_string(result_string);
CImPdu pdu3;
pdu3.SetPBMsg(&msg4);
pdu3.SetServiceId(SID_LOGIN);
pdu3.SetCommandId(CID_LOGIN_RES_USERLOGIN);
pdu3.SetSeqNum(pPdu->GetSeqNum());
pMsgConn->SendPdu(&pdu3);
pMsgConn->Close();
}
}