示例#1
0
        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";
        }
示例#2
0
        void ttserver_OnUserDeleteUserAccount(ref ClientErrorMsg lpClientErrorMsg, ref User lpUser, string szUsername)
        {
            String str = String.Format("User {0} is deleting useraccount {1}",
                                       lpUser.szUsername, szUsername);

            Console.WriteLine(str);

            switch (lpUser.uUserType)
            {
            case UserType.USERTYPE_ADMIN:
                UserAccount ua = new UserAccount();
                foreach (UserAccount u in useraccounts)
                {
                    if (u.szUsername.Equals(szUsername))
                    {
                        ua = u;
                    }
                }
                useraccounts.Remove(ua);
                lpClientErrorMsg.nErrorNo = (int)ClientError.SUCCESS;
                break;

            case UserType.USERTYPE_DEFAULT:
                lpClientErrorMsg.nErrorNo   = (int)ClientError.CMDERR_NOT_AUTHORIZED;
                lpClientErrorMsg.szErrorMsg = "Not allowed!";
                break;

            default:
                break;
            }
        }
示例#3
0
 void ttclient_OnCmdError(int nCmdID, ClientErrorMsg clienterrormsg)
 {
     //clear create account if unsuccessful
     if (nCmdID == create_cmdid)
     {
         account_create = new UserAccount();
         MessageBox.Show(clienterrormsg.szErrorMsg);
     }
 }
示例#4
0
        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);
            }
        }
示例#5
0
        void ttserver_OnUserAddServerBan(ref ClientErrorMsg lpClientErrorMsg, ref User lpBanner, ref User lpBanee)
        {
            UserAccount ua = getUserAccount(lpBanner.szUsername);

            if ((ua.uUserRights & UserRight.USERRIGHT_BAN_USERS) != 0)
            {
                lpClientErrorMsg.nErrorNo = (int)ClientError.SUCCESS;
                banned_ipaddr.Add(lpBanee.szIPAddress);
            }
            else
            {
                lpClientErrorMsg.nErrorNo   = (int)ClientError.CMDERR_NOT_AUTHORIZED;
                lpClientErrorMsg.szErrorMsg = "Not allowed!";
            }
        }
示例#6
0
        void ttserver_OnUserChangeNickname(ref ClientErrorMsg lpClientErrorMsg, ref User lpUser, string szNewNickname)
        {
            String str = String.Format("User {0} is requesting to change nickname to {1}",
                                       lpUser.szNickname, szNewNickname);

            Console.WriteLine(str);

            if (szNewNickname.IndexOf("crap") >= 0)
            {
                lpClientErrorMsg.nErrorNo   = 4567;
                lpClientErrorMsg.szErrorMsg = "Nickname not allowed";
            }
            else
            {
                lpClientErrorMsg.nErrorNo = (int)ClientError.CMDERR_SUCCESS;
            }
        }
示例#7
0
        void ttserver_OnUserChangeStatus(ref ClientErrorMsg lpClientErrorMsg, ref User lpUser, ref int nNewStatusMode, string szNewStatusMsg)
        {
            String str = String.Format("User {0} is requesting to change status message to {1}",
                                       lpUser.szNickname, szNewStatusMsg);

            Console.WriteLine(str);

            if (szNewStatusMsg.IndexOf("crap") >= 0)
            {
                lpClientErrorMsg.nErrorNo   = 4568;
                lpClientErrorMsg.szErrorMsg = "Status not allowed";
            }
            else
            {
                lpClientErrorMsg.nErrorNo = (int)ClientError.CMDERR_SUCCESS;
            }
        }
示例#8
0
 void TeamTalkSrv_OnUserLoginCallback(IntPtr lpTTSInstance, IntPtr lpUserData, ref ClientErrorMsg lpClientErrorMsg, ref User lpUser, ref UserAccount lpUserAccount)
 {
     if (OnUserLogin != null)
     {
         OnUserLogin(ref lpClientErrorMsg, ref lpUser, ref lpUserAccount);
     }
 }
示例#9
0
 void TeamTalkSrv_OnUserAddServerBanCallback(IntPtr lpTTSInstance, IntPtr lpUserData, ref ClientErrorMsg lpClientErrorMsg, ref User lpBanner, ref User lpBanee)
 {
     if (OnUserAddServerBan != null)
     {
         OnUserAddServerBan(ref lpClientErrorMsg, ref lpBanner, ref lpBanee);
     }
 }
示例#10
0
 void TeamTalkSrv_OnUserAddServerBanIPAddressCallback(IntPtr lpTTSInstance, IntPtr lpUserData, ref ClientErrorMsg lpClientErrorMsg, ref User lpBanner, string szIPAddress)
 {
     if (OnUserAddServerBanIPAddress != null)
     {
         OnUserAddServerBanIPAddress(ref lpClientErrorMsg, ref lpBanner, szIPAddress);
     }
 }
示例#11
0
 void TeamTalkSrv_OnUserDeleteUserAccountCallback(IntPtr lpTTSInstance, IntPtr lpUserData, ref ClientErrorMsg lpClientErrorMsg, ref User lpUser, string szUsername)
 {
     if (OnUserDeleteUserAccount != null)
     {
         OnUserDeleteUserAccount(ref lpClientErrorMsg, ref lpUser, szUsername);
     }
 }
示例#12
0
 void TeamTalk5Srv_OnUserChangeNicknameCallback(IntPtr lpTTSInstance, IntPtr lpUserData, ref ClientErrorMsg lpClientErrorMsg, ref User lpUser, string szNewNickname)
 {
     if (OnUserChangeNickname != null)
     {
         OnUserChangeNickname(ref lpClientErrorMsg, ref lpUser, szNewNickname);
     }
 }
示例#13
0
 void TeamTalk5Srv_OnUserChangeStatusCallback(IntPtr lpTTSInstance, IntPtr lpUserData, ref ClientErrorMsg lpClientErrorMsg, ref User lpUser, ref int nNewStatusMode, string szNewStatusMsg)
 {
     if (OnUserChangeStatus != null)
     {
         OnUserChangeStatus(ref lpClientErrorMsg, ref lpUser, ref nNewStatusMode, szNewStatusMsg);
     }
 }
示例#14
0
 static void ttclient_OnCmdError(int nCmdID, ClientErrorMsg clienterrormsg)
 {
     Console.WriteLine("Command with ID #{0} failed with the following error: {1}",
                       nCmdID, clienterrormsg.szErrorMsg);
 }