Example #1
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            if (WebSocketManager.IsConnected() == false)
            {
                WebSocketManager.InitWebSocket();
                if (WebSocketManager.IsConnected() == false)
                {
                    string tips = string.Format("无法连接服务器,请确保服务器地址为{0},且处于开启状态", AppValues.SERVER_URL);
                    MessageBox.Show(this, tips, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }

            string inputUsername = txtUsername.Text.Trim();
            string inputPassword = txtPassword.Text.Trim();

            if (string.IsNullOrEmpty(inputUsername))
            {
                MessageBox.Show("用户名不能为空", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (string.IsNullOrEmpty(inputPassword))
            {
                MessageBox.Show("密码不能为空", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            LoginRequest.Builder builder = LoginRequest.CreateBuilder();
            builder.SetUsername(inputUsername);
            MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
            string passwordMD5           = BitConverter.ToString(md5.ComputeHash(System.Text.Encoding.UTF8.GetBytes(inputPassword))).Replace("-", "").ToUpper();

            builder.SetPasswordMD5(passwordMD5);
            WebSocketManager.SendMessage(RpcNameEnum.Login, builder.Build().ToByteArray(), OnLoginCallback);
        }
Example #2
0
    private void Request(string userName)
    {
        LoginRequest.Builder request = LoginRequest.CreateBuilder();
        request.SetUserName(userName);
        var bytes = request.Build().ToByteArray();

        App.NetworkManager.Request("Login", bytes, Response);
    }
Example #3
0
 /// <summary>
 /// Giriş İsteği yolla
 /// </summary>
 /// <param name="nUsername">Kullanıcı İsmi</param>
 /// <param name="nPassword">Parola</param>
 public void SendLoginRequest(string nUsername, string nPassword)
 {
     this.username = nUsername;
     this.password = nPassword;
     LoginRequest.Builder Lr = new LoginRequest.Builder();
     Lr.SetName(nUsername);
     Lr.SetPassword(nPassword);
     Lr.SetVersion("asdas");
     Lr.SetEmail("sjdjsj");
     SendBytes(CreateCommand(XCommunicateEnum.LoginRequest, Lr.Build().ToByteArray()));
 }