//登录 private void button1_Click(object sender, EventArgs e) { string username = textBox1.Text.Trim(); string password = textBox2.Text.Trim(); if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password)) { MessageBox.Show("请输入完整信息"); return; } if (access.SearchUserID(username) < 0) { MessageBox.Show("用户不存在!"); return; } if (password != access.GetUserPassword(username)) { MessageBox.Show("密码错误!", "错误"); return; } var userVector = timeline.ToVector(); var storedVectors = access.FetchKeyboardVectors(username); if (!Verifier.Verify(userVector, storedVectors)) { MessageBox.Show("键盘特征非用户本人!", "错误"); InitializeKeyboardVariable(); textBox2.Clear(); textBox2.Focus(); return; } access.InsertKeyboardData(username, userVector); #if KEYBOARD_DEBUG MessageBox.Show("OK!"); InitializeKeyboardVariable(); return; #endif //构造登录信息 LoginModel loginModel = new LoginModel(); loginModel.username = username; loginModel.password = password; //发送登录信息 MyMessage loginMsg = new MyMessage(); loginMsg.from = username; loginMsg.to = "server"; loginMsg.type = "login"; loginMsg.loginModel = loginModel; server.sendMsg(loginMsg, ServerIP.getServerIPEndPoint()); }
public void sendHeartBeatMsg() { MyMessage heartBeatMsg = new MyMessage(); heartBeatMsg.from = currentUsername; heartBeatMsg.to = "server"; heartBeatMsg.type = "heart"; heartBeatMsg.content = "heart"; while (true) { sendMsg(heartBeatMsg, ServerIP.getServerIPEndPoint()); Thread.Sleep(HEART_BEAT_SLEEP_TIME); } }