本文整理汇总了C++中CUser::Disconnect方法的典型用法代码示例。如果您正苦于以下问题:C++ CUser::Disconnect方法的具体用法?C++ CUser::Disconnect怎么用?C++ CUser::Disconnect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CUser
的用法示例。
在下文中一共展示了CUser::Disconnect方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Timer_UpdateSessions
uint32 CEbenezerDlg::Timer_UpdateSessions(void * lpParam)
{
while (g_bRunning)
{
SessionMap & sessMap = g_pMain->m_socketMgr.GetActiveSessionMap();
foreach (itr, sessMap)
{
CUser * pUser = TO_USER(itr->second);
uint32 timeout = KOSOCKET_TIMEOUT;
// User has authed, but isn't in-game yet (creating a character, or is waiting for the game to load).
if (!pUser->m_strAccountID.empty() && !pUser->isInGame())
timeout = KOSOCKET_LOADING_TIMEOUT;
// Disconnect timed out sessions
if ((UNIXTIME - pUser->GetLastResponseTime()) >= timeout)
{
pUser->Disconnect();
continue;
}
// Update the player, and hence any skill effects while we're here.
if (pUser->isInGame())
pUser->Update();
}
g_pMain->m_socketMgr.ReleaseLock();
sleep(30 * SECOND);
}
示例2: SelCharToAgent
void CUser::SelCharToAgent(Packet & pkt)
{
Packet result(WIZ_SEL_CHAR);
std::string strUserID, strAccountID;
uint8 bInit;
pkt >> strAccountID >> strUserID >> bInit;
if (strAccountID.empty() || strAccountID.size() > MAX_ID_SIZE
|| strUserID.empty() || strUserID.size() > MAX_ID_SIZE
|| strAccountID != m_strAccountID)
{
Disconnect();
return;
}
// Disconnect any currently logged in sessions.
CUser *pUser = g_pMain->GetUserPtr(strUserID, TYPE_CHARACTER);
if (pUser && (pUser->GetSocketID() != GetSocketID()))
{
pUser->Disconnect();
// And reject the login attempt (otherwise we'll probably desync char data)
result << uint8(0);
Send(&result);
return;
}
result << strUserID << bInit;
g_pMain->AddDatabaseRequest(result, this);
}
示例3: LoginProcess
void CUser::LoginProcess(Packet & pkt)
{
// Enforce only one login request per session
// It's common for players to spam this at the server list when a response isn't received immediately.
if (!m_strAccountID.empty())
return;
Packet result(WIZ_LOGIN);
CUser * pUser;
std::string strAccountID, strPasswd;
pkt >> strAccountID >> strPasswd;
if (strAccountID.empty() || strAccountID.size() > MAX_ID_SIZE
|| strPasswd.empty() || strPasswd.size() > MAX_PW_SIZE)
goto fail_return;
pUser = g_pMain->GetUserPtr(strAccountID, TYPE_ACCOUNT);
if (pUser && (pUser->GetSocketID() != GetSocketID()))
{
pUser->Disconnect();
goto fail_return;
}
result << strPasswd;
m_strAccountID = strAccountID;
g_pMain->AddDatabaseRequest(result, this);
return;
fail_return:
result << uint8(-1);
Send(&result);
}