本文整理汇总了C++中CImUser::SetUser方法的典型用法代码示例。如果您正苦于以下问题:C++ CImUser::SetUser方法的具体用法?C++ CImUser::SetUser怎么用?C++ CImUser::SetUser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CImUser
的用法示例。
在下文中一共展示了CImUser::SetUser方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _HandleValidateResponse
void CDBServConn::_HandleValidateResponse(CImPduValidateResponse* pPdu)
{
string user_name(pPdu->GetUserName(), pPdu->GetUserNameLen());
uint32_t result = pPdu->GetResult();
CDbAttachData attach_data(pPdu->GetAttachData(), pPdu->GetAttachLen());
log("HandleValidateResp, user_name=%s, result=%d\n", user_name.c_str(), result);
CImUser* pImUser = CImUserManager::GetInstance()->GetImUserByName(user_name);
CMsgConn* pMsgConn = NULL;
if (!pImUser) {
// can not find the client connection,
// maybe the client is closed before the DB response arrived
// do nothing
log("ImUser for user_name=%s not exist\n", user_name.c_str());
return;
} else {
pMsgConn = pImUser->GetUnValidateMsgConn(attach_data.GetHandle());
if (!pMsgConn || pMsgConn->IsOpen()) {
log("no such connection or is validated, user_name=%s\n", user_name.c_str());
return;
}
}
if (result != 0) {
result = REFUSE_REASON_DB_VALIDATE_FAILED;
}
// validate OK, set client validate past, and send FriendListRequest to db storage server
// else close the client connection
if (result == 0) {
user_info_t* user = pPdu->GetUserInfo();
pImUser->SetUser(user);
pImUser->SetValidated();
uint32_t user_id = user->user_id;
CImUserManager::GetInstance()->AddImUserById(user_id, pImUser);
pImUser->KickOutSameClientType(pMsgConn->GetClientType(), pMsgConn);
CRouteServConn* pRouteConn = get_route_serv_conn();
if (pRouteConn) {
CImPduServerKickUser kickPdu(user_id, pMsgConn->GetClientType(), KICK_REASON_DUPLICATE_USER);
pRouteConn->SendPdu(&kickPdu);
}
string token = create_uuid();
log("user_name: %s, uid: %d, token:%s\n", user_name.c_str(), user->user_id, token.c_str());
pMsgConn->SetToken(token);
pMsgConn->SetOpen();
pMsgConn->SendUserActionLog(USER_ACTION_TYPE_LOGIN);
pMsgConn->SendUserStatusUpdate(USER_STATUS_ONLINE);
pImUser->ValidateMsgConn(token, pMsgConn);
CImPduLoginResponse pduLR(result, pImUser->GetIMOnlineStatus(), user, (char*)token.c_str());
pduLR.SetReserved(pPdu->GetReserved());
pMsgConn->SendPdu(&pduLR);
} else {
CImPduLoginResponse pduLR(result);
pduLR.SetReserved(pPdu->GetReserved());
pMsgConn->SendPdu(&pduLR);
//pMsgConn->Close();
}
}