public static void SIN(Socket accept) { byte[] receive = new byte[1024]; byte[] clear_Receive; string back_Code = ""; MySQLConnectionClass mySQLC = new MySQLConnectionClass(); accept.Send(Encoding.UTF8.GetBytes("OK")); journal += "\n" + DateTime.Now.ToString() + ":"; journal += accept.RemoteEndPoint.ToString() + ",Action:Send 'OK'\n"; int len = accept.Receive(receive); clear_Receive = receive.Take(len).ToArray(); back_Code = Encoding.UTF8.GetString(clear_Receive); journal += "\n" + DateTime.Now.ToString() + ":"; journal += accept.RemoteEndPoint.ToString() + ",Action:Receive '" + back_Code + "'\n"; string[] tmp = back_Code.Split("#"); int user_Id = Convert.ToInt32(tmp[0]); bool is_Password = mySQLC.is_Password(user_Id, tmp[1]); if (is_Password) { accept.Send(Encoding.UTF8.GetBytes("OK")); journal += "\n" + DateTime.Now.ToString() + ":"; journal += accept.RemoteEndPoint.ToString() + ",Action:Send 'OK'\n"; } else { accept.Send(Encoding.UTF8.GetBytes("NO")); journal += "\n" + DateTime.Now.ToString() + ":"; journal += accept.RemoteEndPoint.ToString() + ",Action:Send 'NO'\n"; } mySQLC.stop_Connect_To_DB(); }
public static void REG(Socket accept) { byte[] receive = new byte[1024]; byte[] clear_Receive; MySQLConnectionClass mySQLC = new MySQLConnectionClass(); string back_Code = ""; accept.Send(Encoding.UTF8.GetBytes("OK")); journal += "\n" + DateTime.Now.ToString() + ":"; journal += accept.RemoteEndPoint.ToString() + ",Action:Send 'OK'\n"; int len = accept.Receive(receive); clear_Receive = receive.Take(len).ToArray(); back_Code = Encoding.UTF8.GetString(clear_Receive); journal += "\n" + DateTime.Now.ToString() + ":"; journal += accept.RemoteEndPoint.ToString() + ",Action:Receive '" + back_Code + "'\n"; string[] tmp = back_Code.Split("#"); string temp_Name = tmp[0]; int temp_ID = Convert.ToInt32(tmp[1]); string temp_Password = tmp[2]; bool have = mySQLC.search_User(temp_ID); if (have) { accept.Send(Encoding.UTF8.GetBytes("NO")); journal += "\n" + DateTime.Now.ToString() + ":"; journal += accept.RemoteEndPoint.ToString() + ",Action:Send 'NO'\n"; return; } else { mySQLC.write_To_usertable(temp_Name, temp_ID, temp_Password); accept.Send(Encoding.UTF8.GetBytes("OK")); journal += "\n" + DateTime.Now.ToString() + ":"; journal += accept.RemoteEndPoint.ToString() + ",Action:Send 'OK'\n"; } mySQLC.stop_Connect_To_DB(); }