void ttserver_OnUserCreateUserAccount(ref ClientErrorMsg lpClientErrorMsg, ref User lpUser, ref UserAccount lpUserAccount) { String str = String.Format("User {0} is creating useraccount {1}", lpUser.szUsername, lpUserAccount.szUsername); Console.WriteLine(str); switch (lpUser.uUserType) { case UserType.USERTYPE_ADMIN: // remove existing user account UserAccount ua = new UserAccount(); foreach (UserAccount u in useraccounts) { if (u.szUsername.Equals(lpUserAccount.szUsername)) ua = u; } useraccounts.Remove(ua); // add user account to list useraccounts.Add(lpUserAccount); lpClientErrorMsg.nErrorNo = (int)ClientError.SUCCESS; break; case UserType.USERTYPE_DEFAULT: lpClientErrorMsg.nErrorNo = (int)ClientError.CMDERR_NOT_AUTHORIZED; lpClientErrorMsg.szErrorMsg = "Not allowed!"; break; default: break; } }
void ttclient_OnCmdError(int nCmdID, ClientErrorMsg clienterrormsg) { if (nCmdID == login_cmdid) { login_cmdid = 0; //reset cmdid button1.Enabled = true; nickTextBox.Enabled = true; usernameTextBox.Enabled = true; passwdTextBox.Enabled = true; MessageBox.Show(clienterrormsg.szErrorMsg); } }
void ttserver_OnUserAddServerBanIPAddress(ref ClientErrorMsg lpClientErrorMsg, ref User lpBanner, string szIPAddress) { UserAccount ua = getUserAccount(lpBanner.szUsername); if ((ua.uUserRights & UserRight.USERRIGHT_BAN_USERS) != 0) { lpClientErrorMsg.nErrorNo = (int)ClientError.SUCCESS; banned_ipaddr.Add(szIPAddress); } else { lpClientErrorMsg.nErrorNo = (int)ClientError.CMDERR_NOT_AUTHORIZED; lpClientErrorMsg.szErrorMsg = "Not allowed!"; } }
void ttserver_OnUserLogin(ref ClientErrorMsg lpClientErrorMsg, ref User lpUser, ref UserAccount lpUserAccount) { String str = String.Format("Login attempt from IP {0}, username={1}, password={2}", lpUser.szIPAddress, lpUserAccount.szUsername, lpUserAccount.szPassword); Console.WriteLine(str); foreach (UserAccount u in useraccounts) { // validate user account if (u.szUsername.Equals(lpUserAccount.szUsername) && u.szPassword.Equals(lpUserAccount.szPassword)) { // manually copy every field lpUserAccount.szUsername = u.szUsername; lpUserAccount.szPassword = u.szPassword; lpUserAccount.uUserRights = u.uUserRights; lpUserAccount.uUserType = UserType.USERTYPE_ADMIN; lpClientErrorMsg.nErrorNo = (int)ClientError.SUCCESS; return; } } // login rejected lpClientErrorMsg.nErrorNo = (int)ClientError.CMDERR_INVALID_ACCOUNT; lpClientErrorMsg.szErrorMsg = "Invalid username or password"; }
void ttclient_OnInternalError(ClientErrorMsg clienterrormsg) { MessageBox.Show(clienterrormsg.szErrorMsg, "Internal Error"); }
void ttclient_OnCmdError(int nCmdID, ClientErrorMsg clienterrormsg) { MessageBox.Show(clienterrormsg.szErrorMsg, "Command Error"); }
void ttclient_OnCmdError(int nCmdID, ClientErrorMsg clienterrormsg) { //clear create account if unsuccessful if (nCmdID == create_cmdid) { account_create = new UserAccount(); MessageBox.Show(clienterrormsg.szErrorMsg); } }
static void ttclient_OnCmdError(int nCmdID, ClientErrorMsg clienterrormsg) { Console.WriteLine("Command with ID #{0} failed with the following error: {1}", nCmdID, clienterrormsg.szErrorMsg); }