#include <nAuthentication.h>
Public Member Functions | |
typedef void | UserPasswordCallback (nPasswordRequest const &request, nPasswordAnswer &answer) |
callback where the game can register the password request/lookup | |
typedef void | LoginResultCallback (nCheckResult const &result) |
callback where the game can register the login success | |
Static Public Member Functions | |
static void | SetUserPasswordCallback (UserPasswordCallback *callback) |
let the game register the callbacks | |
static void | SetLoginResultCallback (LoginResultCallback *callback) |
static void | HandlePasswordRequest (nMessage &m) |
network handlers | |
static void | HandlePasswordAnswer (nMessage &m) |
static bool | RequestLogin (const tString &authority, const tString &username, nNetObject &user, const tOutput &message) |
on the server: request user authentification from login slot | |
static void | OnBreak () |
call when you have some time for lengthy authentication queries to servers |
Definition at line 35 of file nAuthentication.h.
typedef void nAuthentication::UserPasswordCallback | ( | nPasswordRequest const & | request, | |
nPasswordAnswer & | answer | |||
) |
callback where the game can register the password request/lookup
typedef void nAuthentication::LoginResultCallback | ( | nCheckResult const & | result | ) |
callback where the game can register the login success
static void nAuthentication::SetUserPasswordCallback | ( | UserPasswordCallback * | callback | ) | [static] |
let the game register the callbacks
Referenced by ePlayer::ePlayer().
static void nAuthentication::SetLoginResultCallback | ( | LoginResultCallback * | callback | ) | [static] |
Referenced by ePlayer::ePlayer(), and nServerInfo::GiveSmallServerInfo().
void nAuthentication::HandlePasswordRequest | ( | nMessage & | m | ) | [static] |
network handlers
Definition at line 130 of file nAuthentication.cpp.
References Cheater(), nMessage::End(), nKrawall::nPasswordRequest::failureOnLastTry, FinishHandlePasswordRequest(), nKrawall::nPasswordRequest::message, nKrawall::nMethod::method, nCLIENT, tString::NetFilter(), nPasswordAnswer, nPasswordRequest, nKrawall::nMethod::prefix, nMessage::ReadRaw(), nKrawall::ReadSalt(), s_inUse, nMessage::SenderID(), sn_GetNetState(), st_ToDo(), nKrawall::nMethod::suffix, and nKrawall::nPasswordAnswer::username.
00131 { 00132 if (m.SenderID() > 0 || sn_GetNetState() != nCLIENT) 00133 Cheater(m.SenderID()); 00134 00135 sn_answer = nKrawall::nPasswordAnswer(); 00136 sn_request = nKrawall::nPasswordRequest(); 00137 00138 // already in the process: return without answer 00139 if ( s_inUse ) 00140 return; 00141 s_inUse = true; 00142 00143 // read salt and username from the message 00144 ReadSalt(m, sn_salt); 00145 00146 // read the username as raw as sanely possible 00147 m.ReadRaw(sn_answer.username); 00148 sn_answer.username.NetFilter(); 00149 00150 m >> sn_request.message; 00151 if (!m.End()) 00152 { 00153 m >> sn_request.failureOnLastTry; 00154 } 00155 else 00156 { 00157 sn_request.failureOnLastTry = true; 00158 } 00159 if (!m.End()) 00160 { 00161 // read method, prefix and suffiox 00162 m >> sn_request.method; 00163 m.ReadRaw(sn_request.prefix); 00164 m.ReadRaw(sn_request.suffix); 00165 sn_request.prefix.NetFilter(); 00166 sn_request.suffix.NetFilter(); 00167 } 00168 else 00169 { 00170 // clear them 00171 sn_request.method = "bmd5"; 00172 sn_request.prefix = ""; 00173 sn_request.suffix = ""; 00174 } 00175 00176 // postpone the answer for a better opportunity since it 00177 // most likely involves opening a menu and waiting a while (and we 00178 // are right now in the process of fetching network messages...) 00179 st_ToDo(&FinishHandlePasswordRequest); 00180 }
void nAuthentication::HandlePasswordAnswer | ( | nMessage & | m | ) | [static] |
Definition at line 1021 of file nAuthentication.cpp.
References nMessage::SenderID().
01022 { 01023 #ifdef KRAWALL_SERVER 01024 // find login pricess 01025 nLoginProcess * process = nLoginProcess::Find( m.SenderID() ); 01026 01027 // and delegate to it 01028 if ( process ) 01029 { 01030 process->ProcessClientAnswer( m ); 01031 } 01032 #endif 01033 }
bool nAuthentication::RequestLogin | ( | const tString & | authority, | |
const tString & | username, | |||
nNetObject & | user, | |||
const tOutput & | message | |||
) | [static] |
on the server: request user authentification from login slot
Definition at line 1036 of file nAuthentication.cpp.
References con, and nNetObject::Owner().
Referenced by nServerInfo::GiveSmallServerInfo(), and se_RequestLogin().
01037 { 01038 #ifdef KRAWALL_SERVER 01039 int userID = user.Owner(); 01040 if ( userID <= 0 ) 01041 { 01042 return false; 01043 } 01044 01045 con << tOutput( "$login_message_requested", userID, username, authority ); 01046 01047 // do nothing if there is another login in process for that client 01048 if ( nLoginProcess::Find( userID ) ) 01049 { 01050 return false; 01051 } 01052 01053 // trigger function cascade bouncing between threads 01054 (new nLoginProcess( userID ))->Init( authority, username, user, tString(message) ); 01055 #endif 01056 01057 return true; 01058 }
void nAuthentication::OnBreak | ( | ) | [static] |
call when you have some time for lengthy authentication queries to servers
Definition at line 1061 of file nAuthentication.cpp.
References st_DoToDo().
Referenced by gGame::StateUpdate(), and update_settings().
01062 { 01063 #ifdef KRAWALL_SERVER 01064 nMemberFunctionRunnerTemplate< nLoginProcess >::OnBreak(); 01065 #endif 01066 st_DoToDo(); 01067 }