public void run(){
		
		//Try to establish write connection with client.
		try{
			output = new PrintWriter(userSocket.getOutputStream(), true);
		}catch(IOException e){
			System.out.println("Error writing to client: " + user.getName() + "(" + user.getIP() + ").");
			e.printStackTrace();
		}
		
		//Try to establish read connection with client.
		try{
			clientInput = new BufferedReader( new InputStreamReader(userSocket.getInputStream()) );
		}catch(IOException e){
			System.out.println("Error reading from client: " + user.getName() + "(" + user.getIP() + ").");
			e.printStackTrace();
		}
		
		System.out.println("User I/O established: " + user.getName() + "(" + user.getIP() + ")!");
		
		//Say that user has joined.
		parentServer.log.add("User " + user.getName() + " has joined the chat!");
		
		
		while(stopThread = false){
			
			String a = getClientInput();
			analyzeInput(a);
			sendMessages();
			
		}
		
		
		//Say that user is leaving.
		parentServer.log.add("User " + user.getName() + " has left.");
		
		//Try to disconnect input and output streams.
		try{
			clientInput.close();
			output.close();
		}catch(IOException e){
			System.out.println("Error closing input and output streams for client: " + user.getName() + "(" + user.getIP() + ").");
			e.printStackTrace();
		}
		
		//Try to disconnect input and output streams.
		try{
			userSocket.close();
		}catch(IOException e){
			System.out.println("Error disconnecting client " + "(" + user.getIP() + ").");
			e.printStackTrace();
		}
	}