public static void main(String argv[]) throws Exception {
		boolean running = true;
		
		/* Open up streams */
		BufferedReader inFromUser = new BufferedReader(new InputStreamReader(System.in));
		Socket clientSocket = new Socket("localhost", 3000);

		ObjectInputStream in = new ObjectInputStream(clientSocket.getInputStream());
		ObjectOutputStream out = new ObjectOutputStream(clientSocket.getOutputStream());
		
		/* Confirm connection and set nickname */
		while (((String) in.readObject()).contentEquals("1")) {
			System.out.println("[Server] Please enter nickname.");
			out.writeObject(inFromUser.readLine());
		}		
		System.out.println("[Server] Nickname accepted.");
		
		/* Start chat session */
		new TestListenThread(clientSocket, new ClientInfo(out, in)).start();
		
		String msg, nick;
		while (running) {
			if ((msg = inFromUser.readLine()).equalsIgnoreCase("/exit")) {
				System.out.println("[Client] Disconnecting and exiting.");
				out.writeObject("9");
				running = false;
			} else if (msg.contains("Whisper@")) {
				int i;
				for (i = 8; i < msg.length(); i++) {
					if (msg.charAt(i) == ' ') break;
				}
				nick = msg.substring(8, i);
				out.writeObject("6");
				out.writeObject(nick);
				out.writeObject(msg.substring(i+1, msg.length()));
			} else if (msg.equalsIgnoreCase("/list")) {
				System.out.println("[Client] Requesting list.");
				out.writeObject("4");
			} else {
				out.writeObject("3");
				out.writeObject(msg);
			}
		}
	}