private void button1_Click(object sender, EventArgs e)//登陆 { if (cbUser.Text == "") { MessageBox.Show("用户名不能为空!"); return; } if (tbPwd.Text == "") { MessageBox.Show("没有密码就想登陆吗?"); } string constr = "Server=127.0.0.1;Database=tonghua;User Id=root;Password=5120154230;"; MySqlConnection mycon = new MySqlConnection(constr); mycon.Open(); //打开连接 string check = "select user,password from information where user='******'and password='******'"; MySqlDataAdapter da = new MySqlDataAdapter(check, mycon); //创建适配器 DataSet ds = new DataSet(); //创建数据集 if (da.Fill(ds, "information") != 0) //判断同名 { MessageBox.Show("恭喜你,登陆成功!"); //输出信息 this.Hide(); Socket_Client server = new Socket_Client(); server.StartPosition = FormStartPosition.CenterScreen; server.Show(); } else { MessageBox.Show("用户名或密码错误!"); return; } }
/// <summary> /// 用户点击开放 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void uiButton1_Click(object sender, EventArgs e) { //创建Socket对象 switch (this.uiComboBox1.SelectedIndex) { case -1: case 0: //判断上一次是否按下 if (uiButton1.Selected) { socket_Server.SocketClose(); uiButton1.Text = "开发端口"; uiButton1.Selected = false; break; } socket_Server = new Socket_Server(new IPEndPoint(IPAddress.Parse(this.uiTextBox1.Text ?? "192.168.3.2"), int.Parse(this.uiTextBox2.Text ?? "2000")), this.uiRichTextBox1, this.uiComboBox2); socket_Server.SocketLoad(); uiButton1.Text = "开放完成"; uiButton1.Selected = true; break; case 1: //判断上一次是否按下 if (uiButton1.Selected) { socket_Client.SocketClose(); uiButton1.Text = "链接"; uiButton1.Selected = false; break; } socket_Client = new Socket_Client(new IPEndPoint(IPAddress.Parse(this.uiTextBox1.Text ?? "192.168.3.2"), int.Parse(this.uiTextBox2.Text ?? "2000")), this.uiRichTextBox1, this.uiComboBox2); socket_Client.SocketLoad(); uiButton1.Text = "链接完成"; uiButton1.Selected = true; break; case 2: //判断上一次是否按下 if (uiButton1.Selected) { socket_UDP.SocketClose(); uiButton1.Text = "链接"; uiButton1.Selected = false; break; } socket_UDP = new Socket_UDP.Socket_UDP(new IPEndPoint(IPAddress.Parse(this.uiTextBox1.Text ?? "192.168.3.2"), int.Parse(this.uiTextBox2.Text ?? "2000")), this.uiRichTextBox1, this.uiComboBox2, uiTextBox3); socket_UDP.Socket_Udp(); uiButton1.Text = "链接完成"; uiButton1.Selected = true; break; } this.uiComboBox1.Enabled = uiButton1.Selected ? false : true; }
public void Send_Account_Login(string ID, string PW) { //로그인 계정정보 보내기 Login 토큰 Socket_Client.Send_Receive_ToServer("Login;" + ID + ";" + PW + ";"); }
public void Send_Update_UserData(string data_stream) { //아이디와 함께 변경할 캐릭터 정보 보내기 Data 토큰 Socket_Client.Send_Receive_ToServer("Data;" + Singletone_PlayerManager.singletone_Player.PlayerInformaion.GetDataOne(UI_Player_Information.ID) + ";" + data_stream + ";"); }
//서버로 보내는 부분 public void Send_Account_Create_New(string ID, string PW) { //새로만드는 계정정보 보내기 NewAccount 토큰 Socket_Client.Send_Receive_ToServer("NewAccount;" + ID + ";" + PW + ";"); }