public void Registration(string inputData) { if (!registered) { string command; server.AddConnection(this); while (!registered) { string[] RegInput = inputData.Split(' '); if (dbCheck(RegInput) == "#Server: _User_Not_In_Db") { this.userLogin = RegInput[2]; this.userPass = RegInput[3]; this.userName = RegInput[4]; using (var db = new ClientContext()) { db.clients.Add(this); db.SaveChanges(); } Id = Guid.NewGuid().ToString(); command = "#Server: _Successful_Registration"; registered = !registered; server.FindSizeOfMessage(command + userName, this.Id); server.RegOrEnterResponce(command + " " + userName, Id); break; } else { server.FindSizeOfMessage("#Server: _Login_Or_Password_Already_Used", this.Id); server.RegOrEnterResponce("#Server: _Login_Or_Password_Already_Used", this.Id); } } } }
ServerObject server; // объект сервера public ClientObject(TcpClient tcpClient, ServerObject serverObject) { Id = Guid.NewGuid().ToString(); client = tcpClient; server = serverObject; serverObject.AddConnection(this); }