private void AcceptClient() { srReceiver = new StreamReader(tcpClient.GetStream()); swSender = new StreamWriter(tcpClient.GetStream()); currUser = srReceiver.ReadLine(); if (currUser != "") { if (Server.htUsers.Contains(currUser) == true) { swSender.WriteLine("0"); swSender.Flush(); CloseConnection(); return; } else if (currUser == "") { swSender.WriteLine("0"); swSender.Flush(); CloseConnection(); return; } else { swSender.WriteLine("1"); swSender.Flush(); Server.AddUser(tcpClient, currUser); } } else { CloseConnection(); return; } try { while ((strResponse = srReceiver.ReadLine()) != "") { if (strResponse == null) { Server.RemoveUser(tcpClient); } else { Server.SendMessage(currUser, strResponse); } } } catch { Server.RemoveUser(tcpClient); } }